Community
Participate
Working Groups
Created attachment 235466 [details] Project for recreate the bug When having muliple levels of inlcudes, and a bottom level include has a "#pragma once" you can end up with a Semantic Error of (Symbol <X> could not be found). I have attached the project that I created to reproduce this, but you can recreate it by just using the files in the project. 1.) Create a new MingW C project 2.) Add S1.c, S2.c, Main.c 3.) Make sure that A1.h, B1.h, C1.h, D1.h, DEF.h, and DEF_2.h are in your inlcude path 4.) build, and make sure indexer is up to date. Problem. Opening S1.c, you can see that the symbol NULL2 is properly resolved. Opening S2.c you can see that NULL2 is not properly resolved and you see the error Description Resource Path Location Type Symbol 'NULL2' could not be resolved S2.c /MDBug line 10 Semantic Error It seems that if you remove the #pragma once from the file DEF.h, then this problem goes away.
I think this is caused by the same issues described in Bug 413768. While investigating that one I often came across 'Undefined Symbol' errors.
Yes, This looks exactly like what I was seeing, and the explanation from Markus Schorn is exactly what I was seeing while debugging the problem Should I close this as a duplicate? Also I noticed that if the "#pragma once" was surrounded by a #ifndef #define #nedif, then the problem does not happen. Also, is there a proposed solution to this problem?
Created attachment 235717 [details] Simpler project to reproduce the bug This is a much simpler case to rep this bug. Just open b.c and notice that SYMBOL is not defined.
Changed version to next since it is reproducible in the current release as well as nightly.
(In reply to Joseph Henry from comment #4) "Next" should not be used in the version field for bugs that are affecting released versions.
The problem is caused by CPreprocessor not recognizing that #ifndef PRAGMAINCLUDE_H_ #define PRAGMAINCLUDE_H_ #endif /* PRAGMAINCLUDE_H_ */ statements in pragmaInclude.h constitute an include guard. This happens due to presence of "#pragma once" before the guard. CPreprocessor should allow "#pragma once" before an include guard similar to how IncludeOrganizer.getNumberOfIncludeGuardStatementsToSkip(IASTTranslationUnit) does it.
New Gerrit change created: https://git.eclipse.org/r/74466
Gerrit change https://git.eclipse.org/r/74466 was merged to [master]. Commit: http://git.eclipse.org/c/cdt/org.eclipse.cdt.git/commit/?id=b741fb552a4dfbb4bd0937ea0e53f4b60fd9a1fc