On Sat, Dec 25, 2010 at 10:00 PM, asmwarrior <asmwarrior@xxxxxxxxx> wrote: > Hi, I have a question about #line directive. I have two files. a.c and b.c > under my c:/ (I use Windows MinGW) > > Now, I have a.c > --------------------------------------------- > int main() > { > #line 1 "b.c" > int a > return 0; > } > --------------------------------------------- > and b.c > --------------------------------------------- > int f1() > { > return 0; > } > --------------------------------------------- > > > Now, I try to run the command line: > > C:\>gcc -c C:\a.c > b.c: In function 'main': > b.c:2:3: error: expected '=', ',', ';', 'asm' or '__attribute__' before > 'return' > C:\> > > You can see, the gcc report error says there are some error in "b.c" but not > "c:\b.c". > which means gcc can not dynamically resolve the file path after the #line > directive. > > Though I can hard-coded the "c:/b.c" to the a.c file, but this is not a good > solution because I would always move the code to other place. > > My question is: Can any one give me an idea to solve this kind of problem? > thanks. > > > One reference is: > http://gcc.gnu.org/onlinedocs/cpp/Line-Control.html#Line-Control Writing a parser generator? Try __LINE__ and __FILE__ instead. http://gcc.gnu.org/onlinedocs/cpp/Standard-Predefined-Macros.html Jeff