Re: can #line directive dynamically resolve the file path?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 2010-12-27 0:38, Jonathan Wakely wrote:
On 26 December 2010 03:00, asmwarrior 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.
Why should it try to resolve anything?  The filename given to #line is
simply a string constant.

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?
What exactly is the problem?  What are you trying to achieve with the
#line directive?
thanks for your reply.

My problem is, I would like the gcc to report error in an absolute path. (This way, If I use an IDE, it can detect the file path and move the caret to the error location.

for example:

both the a.c and b.c was under C:/, then I compile a.c, the error message should be:
c:/b.c:2:3: error:xxxxx


and if I move both a.c and b.c to D:/, then the error message should be:
d:/b.c:2:3: error:xxxxx

This way, I do not need to specify the absolute path(only the relative path is needed) in the #line directive.

thanks.
asmwarrior




[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux