Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > preprocessor in c

Reply
Thread Tools

preprocessor in c

 
 
DotKu
Guest
Posts: n/a
 
      02-14-2008
first here is the code

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

/*errors.c*/
#include <stdio.h>
#define MAX 1000
/* this is the main function */
int main(){
prntf("hello\n");
//const float pi = 3.0;
rturn 0;
}
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>


when i do preprocess with "cl /E error.c" with VS complier
i got message such as:

""""""""""""""""""""""""""""""
....
...
....
#pragma pack(pop)
#line 704 "C:\\Program Files\\Microsoft Visual Studio 8\\VC\\INCLUDE\
\stdio.h"

#line 706 "C:\\Program Files\\Microsoft Visual Studio 8\\VC\\INCLUDE\
\stdio.h"

#line 2 "C:\\DotKu\\Visual Studio 2005\\Projects\\Error\\Error\
\Error.cpp"
....
....
""""""""""""""""""""""""""""""""""

any one know what does these "# 704" means?

 
Reply With Quote
 
 
 
 
Keith Thompson
Guest
Posts: n/a
 
      02-14-2008
DotKu <(E-Mail Removed)> writes:
> first here is the code
>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

> /*errors.c*/
> #include <stdio.h>
> #define MAX 1000
> /* this is the main function */
> int main(){
> prntf("hello\n");
> //const float pi = 3.0;
> rturn 0;
> }
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>


The errors (prntf and rturn) are intentional, right?

> when i do preprocess with "cl /E error.c" with VS complier
> i got message such as:
>
> """"""""""""""""""""""""""""""
> ...
> ..
> ...
> #pragma pack(pop)
> #line 704 "C:\\Program Files\\Microsoft Visual Studio 8\\VC\\INCLUDE\
> \stdio.h"
>
> #line 706 "C:\\Program Files\\Microsoft Visual Studio 8\\VC\\INCLUDE\
> \stdio.h"
>
> #line 2 "C:\\DotKu\\Visual Studio 2005\\Projects\\Error\\Error\
> \Error.cpp"
> ...
> ...
> """"""""""""""""""""""""""""""""""
>
> any one know what does these "# 704" means?


Those are line control directives, a standard feature of the language
that should be explained in your text book. They tell the compiler to
assume that, for example, it's processing line 704 of the specified
file; this affects the __FILE__ and __LINE__ macros, and probably
affects the form of diagnostic messages.

Assume that the preprocessor is implemented as a separate program that
feeds its output to the rest of the compiler. By the time the main
part of the compiler sees your "prntf" typo, it will have processed
several hundred lines of input, mostly from stdio.h and whatever it
#includes, directly or indirectly. But you still want the error
message to refer to line 6 of your file "errors.c". The purpose of
the #line directives is to enable the compiler to keep track of this.

--
Keith Thompson (The_Other_Keith) <(E-Mail Removed)>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
 
Reply With Quote
 
 
 
 
Barry Schwarz
Guest
Posts: n/a
 
      02-14-2008
On Wed, 13 Feb 2008 17:42:02 -0800 (PST), DotKu <(E-Mail Removed)>
wrote:

>first here is the code
>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

>/*errors.c*/


You tell us here that the file extension is c.

>#include <stdio.h>
>#define MAX 1000
>/* this is the main function */
>int main(){
> prntf("hello\n");
> //const float pi = 3.0;
> rturn 0;
>}
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

>
>when i do preprocess with "cl /E error.c" with VS complier
>i got message such as:
>
>""""""""""""""""""""""""""""""
>...
>..
>...
>#pragma pack(pop)
>#line 704 "C:\\Program Files\\Microsoft Visual Studio 8\\VC\\INCLUDE\
>\stdio.h"
>
>#line 706 "C:\\Program Files\\Microsoft Visual Studio 8\\VC\\INCLUDE\
>\stdio.h"
>
>#line 2 "C:\\DotKu\\Visual Studio 2005\\Projects\\Error\\Error\
>\Error.cpp"


Your compiler is telling us it is cpp. Odds are the compiler is the
more accurate of the two which means this is being processed as C++
code and not C code.

>...
>...
>""""""""""""""""""""""""""""""""""
>
>any one know what does these "# 704" means?



Remove del for email

--
Posted via a free Usenet account from http://www.teranews.com

 
Reply With Quote
 
Martin Ambuhl
Guest
Posts: n/a
 
      02-14-2008
DotKu wrote:
> first here is the code


> /*errors.c*/
> #include <stdio.h>
> #define MAX 1000
> /* this is the main function */
> int main(){
> prntf("hello\n");
> //const float pi = 3.0;
> rturn 0;
> }


> when i do preprocess with "cl /E error.c" with VS complier
> i got message such as:


> #pragma pack(pop)
> #line 704 "C:\\Program Files\\Microsoft Visual Studio 8\\VC\\INCLUDE\
> \stdio.h"
>
> #line 706 "C:\\Program Files\\Microsoft Visual Studio 8\\VC\\INCLUDE\
> \stdio.h"
>
> #line 2 "C:\\DotKu\\Visual Studio 2005\\Projects\\Error\\Error\
> \Error.cpp"


> any one know what does these "# 704" means?


1) Your implementation documentation is the right place to look
2) The reference in the diagnostic to "Error.cpp" is suspicious.
Are you _sure_ that you are using a C compiler to compile
a C program?
3) Any compiler will vomit on this code, since "prntf" and "rturn"
have no meaning in it.
3) Any compiler in C89- or C90-compliant mode will also barf
on the '//' style comment.



 
Reply With Quote
 
Malcolm McLean
Guest
Posts: n/a
 
      02-14-2008

"DotKu" <(E-Mail Removed)> wrote in message news:
> first here is the code
>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

> /*errors.c*/
> #include <stdio.h>
> #define MAX 1000
> /* this is the main function */
> int main(){
> prntf("hello\n");
> //const float pi = 3.0;
> rturn 0;
> }
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

>
> when i do preprocess with "cl /E error.c" with VS complier
> i got message such as:
>
> """"""""""""""""""""""""""""""
> ...
> ..
> ...
> #pragma pack(pop)
> #line 704 "C:\\Program Files\\Microsoft Visual Studio 8\\VC\\INCLUDE\
> \stdio.h"
>
> #line 706 "C:\\Program Files\\Microsoft Visual Studio 8\\VC\\INCLUDE\
> \stdio.h"
>
> #line 2 "C:\\DotKu\\Visual Studio 2005\\Projects\\Error\\Error\
> \Error.cpp"
> ...
> ...
> """"""""""""""""""""""""""""""""""
>
> any one know what does these "# 704" means?
>

It claims to have found an error in stdio.h.
Which is suspicious. I suspect that stdio.h illegally defines MAX on your
system.

--
Free games and programming goodies.
http://www.personal.leeds.ac.uk/~bgy1mm

 
Reply With Quote
 
Ben Bacarisse
Guest
Posts: n/a
 
      02-14-2008
"Malcolm McLean" <(E-Mail Removed)> writes:

> "DotKu" <(E-Mail Removed)> wrote in message news:
>> first here is the code
>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

>> /*errors.c*/
>> #include <stdio.h>
>> #define MAX 1000
>> /* this is the main function */
>> int main(){
>> prntf("hello\n");
>> //const float pi = 3.0;
>> rturn 0;
>> }
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

>>
>> when i do preprocess with "cl /E error.c" with VS complier
>> i got message such as:
>>
>> """"""""""""""""""""""""""""""
>> ...
>> ..
>> ...
>> #pragma pack(pop)
>> #line 704 "C:\\Program Files\\Microsoft Visual Studio 8\\VC\\INCLUDE\
>> \stdio.h"
>>
>> #line 706 "C:\\Program Files\\Microsoft Visual Studio 8\\VC\\INCLUDE\
>> \stdio.h"
>>
>> #line 2 "C:\\DotKu\\Visual Studio 2005\\Projects\\Error\\Error\
>> \Error.cpp"
>> ...
>> ...
>> """"""""""""""""""""""""""""""""""
>>
>> any one know what does these "# 704" means?
>>

> It claims to have found an error in stdio.h.
> Which is suspicious. I suspect that stdio.h illegally defines MAX on
> your system.


There's not error report there that I can see. The text "Error" is
just in the OP's file name.

The pre-processor is simply producing line control directives.

--
Ben.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Compiler error occurred when try to use a flexible template expression in preprocessor definesCompiler error occurred when try to use a flexible template expression in preprocessor defines snnn C++ 6 03-14-2005 04:09 PM
C# Preprocessor =?Utf-8?B?SSBhbSBTYW0=?= ASP .Net 2 03-13-2005 02:47 PM
preprocessor, token concatenation, no valid preprocessor token Cronus C++ 1 07-14-2004 11:10 PM
VHDL Preprocessor The Weiss Family VHDL 2 07-14-2004 05:51 AM
Preprocessor conditional compilation variable not being saved Chris P ASP .Net 0 10-28-2003 08:48 PM



Advertisments