开发者

Header file-name as argument

Objective: I have a list of header files (about 50 of them), And each header-file has few arrays with constant elements. I need to write a program to count the elements of开发者_如何学Go the array. And create some other form of output (which will be used by the hardware group).

My solution: I included all the 50 odd files and wrote an application. And then I dumped all the elements of the array into the specified format.

My environment: Visual Studio V6, Windows XP

My problem: Each time there is a new set of Header files, I am now changing the VC++ project settings to point to the new set of header files, and then rebuild.

My question:

A bit in-sane though,

  • Is there any way to mention the header from some command line arguments or something?
  • I just want to avoid re-compiling the source every time...


Standard C and C++ allow you to use a macro in:

#include SOME_MACRO_HERE

The expanded value of SOME_MACRO_HERE must look correct for a #include directive.

Hence, in principle, you could use the MSVC equivalent of:

cc -DSOME_MACRO_HERE='<actualheader.h>' sourcefile.c

Or:

cc -DSOME_MACRO_HERE='"actualheader.h"' sourcefile.c

This seems to provide you with an answer to your first bullet-question.

I'm not convinced you can avoid recompilation - you can (perhaps) avoid editing, though.


Headers are included at compile time so there is no means to change/add headers at runtime.

Why don't you just write a short and simple Perl script that will parse headers and count number of array items?


Actually I arrived at a solution that works.

  • Step-1: The header file-names would be predefined
  • Step-2: Headers (set) with different parameter values will be placed in different folders
  • Step-3: While compiling, point to the path with the appropriate headers

The solution is not what I wanted, but still, it was best I could figure out.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜