Connecting Tech Pros Worldwide Forums | Help | Site Map

is this compilation right?

wenmang@yahoo.com
Guest
 
Posts: n/a
#1: Oct 13 '05
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


Victor Bazarov
Guest
 
Posts: n/a
#2: Oct 13 '05

re: is this compilation right?


wenmang@yahoo.com wrote:[color=blue]
> Here is a function:
> void f(const char *){};[/color]

The semicolon after it is most likely redundant (or even harmful).
[color=blue]
> 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?[/color]

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
Greg Comeau
Guest
 
Posts: n/a
#3: Oct 13 '05

re: is this compilation right?


In article <jhz3f.40826$Tf5.23733@newsread1.mlpsca01.us.to.ve rio.net>,
Victor Bazarov <v.Abazarov@comAcast.net> wrote:[color=blue]
>wenmang@yahoo.com wrote:[color=green]
>> Here is a function:
>> void f(const char *){};[/color]
>
>The semicolon after it is most likely redundant (or even harmful).[/color]

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?
Victor Bazarov
Guest
 
Posts: n/a
#4: Oct 13 '05

re: is this compilation right?


Greg Comeau wrote:[color=blue]
> In article <jhz3f.40826$Tf5.23733@newsread1.mlpsca01.us.to.ve rio.net>,
> Victor Bazarov <v.Abazarov@comAcast.net> wrote:
>[color=green]
>>wenmang@yahoo.com wrote:
>>[color=darkred]
>>>Here is a function:
>>>void f(const char *){};[/color]
>>
>>The semicolon after it is most likely redundant (or even harmful).[/color]
>
>
> 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".[/color]

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

V
wenmang@yahoo.com
Guest
 
Posts: n/a
#5: Oct 13 '05

re: is this compilation right?


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.

wenmang@yahoo.com
Guest
 
Posts: n/a
#6: Oct 13 '05

re: is this compilation right?


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.

mlimber
Guest
 
Posts: n/a
#7: Oct 13 '05

re: is this compilation right?


wenmang@yahoo.com wrote:[color=blue]
> 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.[/color]

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

Victor Bazarov
Guest
 
Posts: n/a
#8: Oct 13 '05

re: is this compilation right?


wenmang@yahoo.com wrote:[color=blue]
> 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?[/color]

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

V
Victor Bazarov
Guest
 
Posts: n/a
#9: Oct 13 '05

re: is this compilation right?


wenmang@yahoo.com wrote:[color=blue]
> 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.[/color]

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

V
Closed Thread


Similar C / C++ bytes