preprocessor in c

D

DotKu

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?
 
K

Keith Thompson

DotKu said:
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.
 
B

Barry Schwarz

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
 
M

Martin Ambuhl

DotKu said:
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.
 
M

Malcolm McLean

DotKu said:
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.
 
B

Ben Bacarisse

Malcolm McLean said:
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top