preprocessor in c

Discussion in 'C Programming' started by DotKu, Feb 14, 2008.

  1. DotKu

    DotKu Guest

    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?
    DotKu, Feb 14, 2008
    #1
    1. Advertising

  2. DotKu <> 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) <>
    Nokia
    "We must do something. This is something. Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"
    Keith Thompson, Feb 14, 2008
    #2
    1. Advertising

  3. On Wed, 13 Feb 2008 17:42:02 -0800 (PST), DotKu <>
    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
    Barry Schwarz, Feb 14, 2008
    #3
  4. 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.
    Martin Ambuhl, Feb 14, 2008
    #4
  5. "DotKu" <> 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
    Malcolm McLean, Feb 14, 2008
    #5
  6. "Malcolm McLean" <> writes:

    > "DotKu" <> 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.
    Ben Bacarisse, Feb 14, 2008
    #6
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Chris P
    Replies:
    0
    Views:
    433
    Chris P
    Oct 28, 2003
  2. The Weiss Family

    VHDL Preprocessor

    The Weiss Family, Jul 14, 2004, in forum: VHDL
    Replies:
    2
    Views:
    3,199
    The Weiss Family
    Jul 14, 2004
  3. =?Utf-8?B?SSBhbSBTYW0=?=

    C# Preprocessor

    =?Utf-8?B?SSBhbSBTYW0=?=, Mar 13, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    1,568
    =?Utf-8?B?SSBhbSBTYW0=?=
    Mar 13, 2005
  4. Replies:
    0
    Views:
    2,662
  5. Cronus
    Replies:
    1
    Views:
    649
    Paul Mensonides
    Jul 15, 2004
Loading...

Share This Page