is this compilation right?

Discussion in 'C++' started by wenmang@yahoo.com, Oct 13, 2005.

  1. Guest

    Hi,

    Here is a function:
    void f(const char *){};

    when I call above function with following statement, it is compiled
    without error:
    f(string("hi")); //create a tmp string object

    Is it right for compiler not even issuing an error?

    wm
     
    , Oct 13, 2005
    #1
    1. Advertising

  2. wrote:
    > Here is a function:
    > void f(const char *){};


    The semicolon after it is most likely redundant (or even harmful).

    > when I call above function with following statement, it is compiled
    > without error:
    > f(string("hi")); //create a tmp string object
    >
    > Is it right for compiler not even issuing an error?


    Shouldn't. Unless you redefined 'string' somehow not to mean
    'std::string'. What is 'string'? Post _complete_ code that you
    claim compiles without an error.

    V
     
    Victor Bazarov, Oct 13, 2005
    #2
    1. Advertising

  3. Greg Comeau Guest

    In article <jhz3f.40826$01.us.to.verio.net>,
    Victor Bazarov <> wrote:
    > wrote:
    >> Here is a function:
    >> void f(const char *){};

    >
    >The semicolon after it is most likely redundant (or even harmful).


    Comeau C/C++ 4.3.3 (Aug 6 2003 15:13:37) for ONLINE_EVALUATION_BETA1
    Copyright 1988-2003 Comeau Computing. All rights reserved.
    MODE:strict errors C++

    "ComeauTest.c", line 1: error: extra ";" ignored,
    In C: A function definition does not end with a semicolon
    In C++: A function definition, extern "C" or namespace,
    does not end with a semicolon
    void f(const char *){};
    ^

    1 error detected in the compilation of "ComeauTest.c".


    --
    Greg Comeau / Celebrating 20 years of Comeauity!
    Comeau C/C++ ONLINE ==> http://www.comeaucomputing.com/tryitout
    World Class Compilers: Breathtaking C++, Amazing C99, Fabulous C90.
    Comeau C/C++ with Dinkumware's Libraries... Have you tried it?
     
    Greg Comeau, Oct 13, 2005
    #3
  4. Greg Comeau wrote:
    > In article <jhz3f.40826$01.us.to.verio.net>,
    > Victor Bazarov <> wrote:
    >
    >> wrote:
    >>
    >>>Here is a function:
    >>>void f(const char *){};

    >>
    >>The semicolon after it is most likely redundant (or even harmful).

    >
    >
    > Comeau C/C++ 4.3.3 (Aug 6 2003 15:13:37) for ONLINE_EVALUATION_BETA1
    > Copyright 1988-2003 Comeau Computing. All rights reserved.
    > MODE:strict errors C++
    >
    > "ComeauTest.c", line 1: error: extra ";" ignored,
    > In C: A function definition does not end with a semicolon
    > In C++: A function definition, extern "C" or namespace,
    > does not end with a semicolon
    > void f(const char *){};
    > ^
    >
    > 1 error detected in the compilation of "ComeauTest.c".


    Yes. It would be only redundant if the function is a member. That's
    why I requested the complete code.

    V
     
    Victor Bazarov, Oct 13, 2005
    #4
  5. Guest

    This is not real code that I was using.

    Here is the question, unfortunately, the include path for our Makefile
    includes too many possible file with the same name, e.g., map which
    from Roguewave and SGI, etc.
    Do I have the way to decipher my final build(maybe partial if necessay
    or with certain compiler option?) to see what exact the header file is
    included and from where?
    Thanks.
     
    , Oct 13, 2005
    #5
  6. Guest

    The reason I am asking is that we have pre-std C++ with name like map.h
    provided by vendor, and at the same time, SGI and other library with
    std C++ are also installed on our unix box. Imaginge that confusion we
    have had.
     
    , Oct 13, 2005
    #6
  7. mlimber Guest

    wrote:
    > This is not real code that I was using.
    >
    > Here is the question, unfortunately, the include path for our Makefile
    > includes too many possible file with the same name, e.g., map which
    > from Roguewave and SGI, etc.
    > Do I have the way to decipher my final build(maybe partial if necessay
    > or with certain compiler option?) to see what exact the header file is
    > included and from where?
    > Thanks.


    There may be a compiler-specific verbosity option that you can use, or
    you could dump the preprocessor output and dig through it. Usually, the
    PP will emit #line statements with the fully qualified filename and
    line number.

    Cheers! --M
     
    mlimber, Oct 13, 2005
    #7
  8. wrote:
    > This is not real code that I was using.
    >
    > Here is the question, unfortunately, the include path for our Makefile
    > includes too many possible file with the same name, e.g., map which
    > from Roguewave and SGI, etc.
    > Do I have the way to decipher my final build(maybe partial if necessay
    > or with certain compiler option?) to see what exact the header file is
    > included and from where?


    Try generating dependencies -- that should show the exact file names.
    Project management is OT here, unfortunately.

    V
     
    Victor Bazarov, Oct 13, 2005
    #8
  9. wrote:
    > The reason I am asking is that we have pre-std C++ with name like map.h
    > provided by vendor, and at the same time, SGI and other library with
    > std C++ are also installed on our unix box. Imaginge that confusion we
    > have had.


    Seven years after the Standard has been approved... It may be time for
    you to straighten out your build environment. Just a thought.

    V
     
    Victor Bazarov, Oct 13, 2005
    #9
    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. Tom
    Replies:
    0
    Views:
    429
  2. =?Utf-8?B?QmlzaG95?=
    Replies:
    0
    Views:
    992
    =?Utf-8?B?QmlzaG95?=
    Dec 28, 2006
  3. C__chp
    Replies:
    4
    Views:
    509
    Puppet_Sock
    Feb 15, 2008
  4. Bogdan
    Replies:
    1
    Views:
    799
    Bogdan
    Jun 16, 2009
  5. Leon
    Replies:
    3
    Views:
    175
    TaeHo Yoo
    Nov 26, 2004
Loading...

Share This Page