×

Discussion Board

Results 1 to 8 of 8
  1. #1
    Registered User
    Join Date
    Jan 2008
    Posts
    6

    Preprocessor directives in Open c++

    Hi,
    We need to use some of the preprocessor commands like #error,# define in open c++
    but when we use them and compile we are getting errors.So, can someone suggest us if there is a way to handle these problems.


    Thank you,

    M.R.Chethan

  2. #2
    (Retired) Nokia Developer Admin.
    Join Date
    Jan 2006
    Location
    Michigan
    Posts
    4,664

    Re: Preprocessor directives in Open c++

    Quote Originally Posted by mrchethan View Post
    Hi,
    We need to use some of the preprocessor commands like #error,# define in open c++
    but when we use them and compile we are getting errors.So, can someone suggest us if there is a way to handle these problems.
    #error is not a standard preprocessor my guess is you have your compiler set for strict compiling and that is giving you the error. are you using #define or # define and in what format?

    I'll see if I can get the FN Expert on this to give you more than my educated guess.

    Ron

  3. #3
    Registered User
    Join Date
    Jan 2008
    Posts
    6

    Re: Preprocessor directives in Open c++

    @Ron
    Hi,
    We are not facing any problem with the #define that is working fine but the problem is only when we use #error. Can you please explain about the strict compiler settings that you were talking about.Thanks for your reply

  4. #4
    Nokia Developer Moderator
    Join Date
    Sep 2004
    Location
    Tampere, Finland
    Posts
    11,359

    Re: Preprocessor directives in Open c++

    You are saying that you're getting errors when compiling a preprocessor directive which is used precisely to throw an error at compile time.

    So, is the error you're getting a sign that the directive works or a sign that it fails? Would you please start by describing when you get the error and what type of error that is?
    -- Lucian

    If you are not yet a DVLUP member it is time to correct that mistake :) Click here to join: http://www.dvlup.com/lucian/Invite

  5. #5
    Registered User
    Join Date
    Jan 2008
    Posts
    6

    Re: Preprocessor directives in Open c++

    @Itomuta
    this is the part of the code that i have written in Open c++

    #if defined(_CL_HAVE_MATH_H)
    #include <math.h>
    #else
    #error "CLucene can't compile without <math.h>"
    #endif

    #if defined(_CL_HAVE_MAP)
    #include <map>
    #else
    #error "CLucene can't compile without the map header"
    #endif

    #if defined(_CL_HAVE_LIST)
    #include <list>
    #else
    #error "CLucene can't compile without the list header"
    #endif

    #if defined(_CL_HAVE_SET)
    #include <set>
    #else
    #error "CLucene can't compile without the set header"
    #endif



    The error message that i am getting is

    #error "CLucene can't compile without <math.h>"
    #error "CLucene can't compile without the map header"
    #error "CLucene can't compile without the list header"
    #error "CLucene can't compile without the set header"


    My doubt is if the #error preprocessor is working then only the "Clucene can't compile without <math.h>" statement only should be printed but it is saying there is a problem with the #error statement

  6. #6
    Nokia Developer Moderator
    Join Date
    Sep 2004
    Location
    Tampere, Finland
    Posts
    11,359

    Re: Preprocessor directives in Open c++

    Until Ron finds a compiler expert to comment on this here's my two cents:

    Different compilers have different approaches to handling the preprocessor directives and they can be more or less verbose about them.

    All the compilers I've tried (Nokia, RVCT, GCC) have different output patterns for the #error directive, some more verbose than others, but they all stop on it while carrying on when it comes to dealing with a #warning directive, just as expected.

    While I could not find any clear specifications on how the Nokia compiler should be handling the #error directive I encourage you to ignore this output formating issue, I do not see it as relevant.
    -- Lucian

    If you are not yet a DVLUP member it is time to correct that mistake :) Click here to join: http://www.dvlup.com/lucian/Invite

  7. #7
    (Retired) Nokia Developer Admin.
    Join Date
    Jan 2006
    Location
    Michigan
    Posts
    4,664

    Re: Preprocessor directives in Open c++

    Quote Originally Posted by mrchethan View Post
    The error message that i am getting is

    #error "CLucene can't compile without <math.h>"
    #error "CLucene can't compile without the map header"
    #error "CLucene can't compile without the list header"
    #error "CLucene can't compile without the set header"


    My doubt is if the #error preprocessor is working then only the "Clucene can't compile without <math.h>" statement only should be printed but it is saying there is a problem with the #error statement
    first let me say this is NOT a standard precompiler directive so any implementation is not a bug. Generally a #error will halt compilation as soon as the first error message is encountered. in this case it is reporting all errors then halting compiling. I can see where this method of reporting all errors is better.

    I'll see what the compiler team thinks

    Ron

  8. #8
    (Retired) Nokia Developer Admin.
    Join Date
    Jan 2006
    Location
    Michigan
    Posts
    4,664

    Re: Preprocessor directives in Open c++

    Just to put this to rest, both C++ Standard and C Standards have similar wording that says
    # error pp-tokens-opt new-line
    causes the implementation to produce a diagnostic message that includes the specified sequence of preporocessing tokens.

    In other words the format of the error message and whether it shall report all error messages and then halt before compiling or not is not implementation sepecified.

    GCC and MWCC compile all error messages, MSVC halts on first one.

    My copies of the standards are old so the clauses may not be exact but I have 16.5 for C++ and 6.8.5 for C

    Ron

Similar Threads

  1. Open C FAQ
    By Nokia Ron in forum Open C/C++
    Replies: 4
    Last Post: 2010-10-01, 09:02
  2. Open C and cleanup safety?
    By kenley in forum Open C/C++
    Replies: 9
    Last Post: 2009-12-23, 04:45
  3. Replies: 8
    Last Post: 2008-09-22, 06:34
  4. Automatic code signing for open source J2ME Apps?
    By gagravarr in forum Series 40 & S60 Platform Feedback Archive
    Replies: 3
    Last Post: 2008-05-12, 06:09
  5. Replies: 3
    Last Post: 2005-10-12, 05:26

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×