Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » C / C++ IDE (CDT) » __BASE_FILE__(semantic errors)
__BASE_FILE__ [message #840948] Tue, 10 April 2012 18:09 Go to next message
Alexander Strebkov is currently offline Alexander StrebkovFriend
Messages: 5
Registered: April 2012
Junior Member
Hi everybody!

I have installed Eclipse Indigo for C/C++ Linux developers on Ubuntu 10.04 x86.

When I use common predefined macro '__BASE_FILE__' Eclipse says
Symbol '__BASE_FILE__' could not be resolved

but compilation is OK. I have to use it so often in my code and Eclipse fills my screen with red lines and bug icons Smile

It is simple to reproduce:
#include <stdio.h>

int main()
{
	printf("%s\n", __BASE_FILE__);
	return 0;
}


How can I fix this?

Probably the screenshot may explain it better Smile
index.php/fa/7852/0/

[Updated on: Tue, 10 April 2012 18:11]

Report message to a moderator

Re: __BASE_FILE__ [message #841315 is a reply to message #840948] Wed, 11 April 2012 06:39 Go to previous messageGo to next message
Axel Mueller is currently offline Axel MuellerFriend
Messages: 1973
Registered: July 2009
Senior Member
That is an error message from the static code analyzer CODAN. It cannot find the symbol __BASE_FILE__ in its index. That's a gcc internal define (therefore compilation works) but I think it is not defined in any header. So you must add this symbol manually to Project Properties->C/C++ General->Paths and Symbols: Symbols (C in your case).

Before you ask
- search this forum
- see the FAQ http://wiki.eclipse.org/CDT/User/FAQ
- google
Re: __BASE_FILE__ [message #841508 is a reply to message #841315] Wed, 11 April 2012 12:05 Go to previous messageGo to next message
Alexander Strebkov is currently offline Alexander StrebkovFriend
Messages: 5
Registered: April 2012
Junior Member
Axel Mueller wrote on Wed, 11 April 2012 02:39
That is an error message from the static code analyzer CODAN. It cannot find the symbol __BASE_FILE__ in its index. That's a gcc internal define (therefore compilation works) but I think it is not defined in any header. So you must add this symbol manually to Project Properties->C/C++ General->Paths and Symbols: Symbols (C in your case).

Yes, captain. But.. other predefined macros such as __FILE__ or __LINE__ are not marked as errors. If I'll add this macro manually then I don't get expected result (file's name).

I can only do one to reduce the Eclipse to silence.
#ifndef __BASE_FILE__
#define __BASE_FILE__ ""
#endif


Looks like it is bug of the analyzer.
Re: __BASE_FILE__ [message #841833 is a reply to message #841508] Wed, 11 April 2012 19:27 Go to previous messageGo to next message
Axel Mueller is currently offline Axel MuellerFriend
Messages: 1973
Registered: July 2009
Senior Member
Quote:
But.. other predefined macros such as __FILE__ or __LINE__ are not marked as errors. If I'll add this macro manually then I don't get expected result (file's name).

Yes, these macros are known to the CDT indexer. You could open a bugzilla request (or submit a patch Smile ) so the indexer does recognize __BASE_FILE__ , too.
In the mean time you can use this workaround

#ifdef __CDT_PARSER__   // symbol is internally defined by the Eclipse CDT parser)
  #define __BASE_FILE__ ""
#endif


Before you ask
- search this forum
- see the FAQ http://wiki.eclipse.org/CDT/User/FAQ
- google
Re: __BASE_FILE__ [message #842061 is a reply to message #841833] Thu, 12 April 2012 01:01 Go to previous messageGo to next message
David Wegener is currently offline David WegenerFriend
Messages: 1445
Registered: July 2009
Senior Member
On 04/11/2012 02:27 PM, Axel Mueller wrote:
> Quote:
>> But.. other predefined macros such as __FILE__ or __LINE__ are not
>> marked as errors. If I'll add this macro manually then I don't get
>> expected result (file's name).
>
> Yes, these macros are known to the CDT indexer. You could open a
> bugzilla request (or submit a patch :) ) so the indexer does recognize
> __BASE_FILE__ , too.
> In the mean time you can use this workaround
>
>
> #ifdef __CDT_PARSER__ // symbol is internally defined by the Eclipse CDT
> parser)
> #define __BASE_FILE__ ""
> #endif
>
One other thing you can try is to duplicate your debug build
configuration and name it indexer. You can then add the __BASE_FILE__
symbol definition to the indexer configuration. Then select this as the
configuration to use as the fixed build configuration in the Indexer
properties. When the indexer runs, the symbol will be defined but when
you run the debug configuration it won't be and the compiler will use
the built in value.
Re: __BASE_FILE__ [message #842286 is a reply to message #842061] Thu, 12 April 2012 06:42 Go to previous messageGo to next message
Alexander Strebkov is currently offline Alexander StrebkovFriend
Messages: 5
Registered: April 2012
Junior Member
David Wegener wrote on Wed, 11 April 2012 21:01
One other thing you can try is to duplicate your debug build
configuration and name it indexer. You can then add the __BASE_FILE__
symbol definition to the indexer configuration. Then select this as the
configuration to use as the fixed build configuration in the Indexer
properties. When the indexer runs, the symbol will be defined but when
you run the debug configuration it won't be and the compiler will use
the built in value.

This is problem of the static analyzer, not the indexer.

Thanks for your efforts guys Smile
Re: __BASE_FILE__ [message #842552 is a reply to message #842286] Thu, 12 April 2012 11:59 Go to previous messageGo to next message
Axel Mueller is currently offline Axel MuellerFriend
Messages: 1973
Registered: July 2009
Senior Member
Quote:
This is problem of the static analyzer, not the indexer.

That is definitely a problem of the indexer! The code analyzer depends on the indexer!
The analyzer finds a symbol and then checks if it is part of the index. If not then it will raise a warning. If the index is complete you will only get a analyzer warning when you indeed use an undefined symbol.


Before you ask
- search this forum
- see the FAQ http://wiki.eclipse.org/CDT/User/FAQ
- google
Re: __BASE_FILE__ [message #842587 is a reply to message #842552] Thu, 12 April 2012 12:40 Go to previous messageGo to next message
Alexander Strebkov is currently offline Alexander StrebkovFriend
Messages: 5
Registered: April 2012
Junior Member
Axel Mueller wrote on Thu, 12 April 2012 07:59
Quote:
This is problem of the static analyzer, not the indexer.

That is definitely a problem of the indexer! The code analyzer depends on the indexer!
The analyzer finds a symbol and then checks if it is part of the index. If not then it will raise a warning. If the index is complete you will only get a analyzer warning when you indeed use an undefined symbol.

Quote:
One other thing you can try is to duplicate your debug build
configuration and name it indexer. You can then add the __BASE_FILE__
symbol definition to the indexer configuration. Then select this as the
configuration to use as the fixed build configuration in the Indexer
properties. When the indexer runs, the symbol will be defined but when
you run the debug configuration it won't be and the compiler will use
the built in value.

So why it isn't working?

I've added to "Path and Symbols" definition of __BASE_FILE__.
Build log says it is:
gcc -D__BASE_FILE__=__FILE__
warning: "__BASE_FILE__" redefined [-Wbuiltin-macro-redefined]

I've also done "Index -> Rebuild" and "Run C/C++ Code Analysis" commands.
But "__BASE_FILE__" is marked as the same problem.

So strange Sad
Re: __BASE_FILE__ [message #842675 is a reply to message #842587] Thu, 12 April 2012 14:17 Go to previous messageGo to next message
Axel Mueller is currently offline Axel MuellerFriend
Messages: 1973
Registered: July 2009
Senior Member
No problem on my side.
1) File->New_> Project: C Project
2) Project name: hello
3) Project type: Executable, Hello World ANSI C
4) open hello.c and replace code with the code from your initial comment
5) Symbol '__BASE_FILE__' could not be resolved
6) Open Project Properties->C/C++ General->Paths and Symbols: Symbols
Click Add and enter __BASE_FILE__ for the name and __FILE__ for the value
OK
=> CODAN warning is gone


Before you ask
- search this forum
- see the FAQ http://wiki.eclipse.org/CDT/User/FAQ
- google
Re: __BASE_FILE__ [message #842676 is a reply to message #842587] Thu, 12 April 2012 14:18 Go to previous messageGo to next message
Axel Mueller is currently offline Axel MuellerFriend
Messages: 1973
Registered: July 2009
Senior Member
No problem on my side.
1) File->New_> Project: C Project
2) Project name: hello
3) Project type: Executable, Hello World ANSI C
4) open hello.c and replace code with the code from your initial comment
5) Symbol '__BASE_FILE__' could not be resolved
6) Open Project Properties->C/C++ General->Paths and Symbols: Symbols
Click Add and enter __BASE_FILE__ for the name and __FILE__ for the value
OK
=> CODAN warning is gone


Before you ask
- search this forum
- see the FAQ http://wiki.eclipse.org/CDT/User/FAQ
- google
Re: __BASE_FILE__ [message #842677 is a reply to message #842587] Thu, 12 April 2012 14:18 Go to previous messageGo to next message
Axel Mueller is currently offline Axel MuellerFriend
Messages: 1973
Registered: July 2009
Senior Member
No problem on my side.
1) File->New_> Project: C Project
2) Project name: hello
3) Project type: Executable, Hello World ANSI C
4) open hello.c and replace code with the code from your initial comment
5) Symbol '__BASE_FILE__' could not be resolved
6) Open Project Properties->C/C++ General->Paths and Symbols: Symbols
Click Add and enter __BASE_FILE__ for the name and __FILE__ for the value
OK
=> CODAN warning is gone


Before you ask
- search this forum
- see the FAQ http://wiki.eclipse.org/CDT/User/FAQ
- google
Re: __BASE_FILE__ [message #842681 is a reply to message #842587] Thu, 12 April 2012 14:19 Go to previous messageGo to next message
Axel Mueller is currently offline Axel MuellerFriend
Messages: 1973
Registered: July 2009
Senior Member
No problem on my side.
1) File->New_> Project: C Project
2) Project name: hello
3) Project type: Executable, Hello World ANSI C
4) open hello.c and replace code with the code from your initial comment
5) Symbol '__BASE_FILE__' could not be resolved
6) Open Project Properties->C/C++ General->Paths and Symbols: Symbols
Click Add and enter __BASE_FILE__ for the name and __FILE__ for the value
OK
=> CODAN warning is gone


Before you ask
- search this forum
- see the FAQ http://wiki.eclipse.org/CDT/User/FAQ
- google
Re: __BASE_FILE__ [message #842703 is a reply to message #842677] Thu, 12 April 2012 14:48 Go to previous message
Alexander Strebkov is currently offline Alexander StrebkovFriend
Messages: 5
Registered: April 2012
Junior Member
Quote:
=> CODAN warning is gone

After the Eclipse was restarted, it is gone for me too Smile
Thank you very much indeed!
Previous Topic:Installation help
Next Topic:installed CDT successfully,but no C++project in new
Goto Forum:
  


Current Time: Thu Apr 18 11:43:47 GMT 2024

Powered by FUDForum. Page generated in 0.03633 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top