Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
11/13/03 01:55
Read: times


 
#58482 - Preprocessor misconceptions
Responding to: ???'s previous message
"if the error line is in one of my includeded file(preprocessor file),why not the compiler prompt error in that special file"

Because, as Donald suggested, the most likely errors are things like missing semicolons, braces, etc.
Obviously, the compiler can't actually detect that a semicolon, brace, etc, is not there; all it knows is that it has found an sbit keyword, and the sbit keyword is not allowed according to where it thinks it is within your source code!

"it first go through and compile the preprocessor file"

Wrong.
You need to review the operation of the preprocessor - it just does text inclusion/substitution; it does not do any compilation.
The preprocessor has absolutely no knowledge whatsoever of the 'C' language syntax!

You can consider the preprocessor as a completely separate application from the compiler (in some implementations, it actually is); the source file is first passed to the preprocessor, then the output of the preprocessor is fed to the compiler - the compiler never actually "sees" your original source files with the #includes and #defines.

My suggested technique allows you to view the preprocessor output - and thus, hopefully, spot any errors that are otherwise "hidden" by #defines and/or #includes.

You can even feed this preprocessor output to the Compiler - this might clarify the message.

"why not the compiler prompt error immediately after that #include "xxx.h" line?"
See above - it does!

Instead of arguing, why don't you just try it?
Believe me (and Donald) - in situations like this, it will often give you the answer!
A case in point: http://www.keil.com/discuss/docs/thread3603.htm

List of 17 messages in thread
TopicAuthorDate
help!compile error!!            01/01/70 00:00      
   RE: help!compile error!!            01/01/70 00:00      
      RE: help!compile error!!            01/01/70 00:00      
   more compile information!            01/01/70 00:00      
   RE: help!compile error!!            01/01/70 00:00      
      RE: help!compile error!!            01/01/70 00:00      
   Preprocessor?            01/01/70 00:00      
   RE: help!compile error!!            01/01/70 00:00      
      RE: help!compile error!!            01/01/70 00:00      
         RE: help!compile error!!            01/01/70 00:00      
            Preprocessor misconceptions            01/01/70 00:00      
               RE: Preprocessor misconceptions            01/01/70 00:00      
   RE: help!compile error!!            01/01/70 00:00      
      RE: help!compile error!!            01/01/70 00:00      
         RE: help!compile error!!            01/01/70 00:00      
      RE:compile error!! which compiler?            01/01/70 00:00      
         RE: RE:compile error!! which compiler?            01/01/70 00:00      

Back to Subject List