From: Clive M. <cli...@ms...> - 2009-09-15 21:23:46
|
g++ --help emits this: Usage: g++ [options] file... Options: -pass-exit-codes Exit with highest error code from a phase --help Display this information . . . -E Preprocess only; do not compile, assemble or link -S Compile only; do not assemble or link -c Compile and assemble, but do not link -o <file> Place the output into <file> -x <language> Specify the language of the following input files Permissible languages include: c c++ assembler none 'none' means revert to the default behavior of guessing the language based on the file's extension So Roman, it looks as if the man page has a discrepancy with the command-line help. I have just tried -x (the 'none' mentioned above) but it too does not "guess" correctly that it is dealing with a c file. All of this wouldn't be an issue if were not using an IDE. The IDE can only use a common set of flags for all the files in the project. I think my best work around will be to compile the c++ module and make a library out of it, then link with the library from my c code. Will I run into c++ symbol naming issues if I use gcc to link to a c++ derived library? Clive. > To: min...@li... > From: DXD...@ya... > Date: Wed, 16 Sep 2009 00:18:32 +0400 > Subject: Re: [Mingw-users] for a c file g++ emits c++ warnings > > Keith Marshall > <kei...@us...> писал в > своём письме Tue, 15 Sep 2009 17:04:01 +0400: > > > This is a GCC feature[*], rather than MinGW specific; I see exactly > > the same with the native compiler: > > > > $ g++ --version > > g++ (GCC) 4.2.4 (Ubuntu 4.2.4-1ubuntu4) > > Copyright (C) 2007 Free Software Foundation, Inc. > > [...] > > > > $ g++ -W -Wall test.c > > test.c: In function `int main()': > > test.c:6: error: invalid conversion from `void*' to `char*' > > > > while again: > > > > $ g++ -W -Wall -x c test.c > > > > is silent. (It would seem to be a GCC bug, that `-x c' is required > > to inform g++ that test.c is a C source file; as I read `info gcc', > > the .c extension on the file name is specific to C, (not C++), and > > is therefore _supposed_ to deliver the same effect). > > It's not even a bug, as the man page says: > > g++ is a program that calls GCC and treats .c, .h and .i files as C++ > source files instead of C source files unless −x is used, and > automatically specifies linking against the C++ library. > > > [*] Of course, this "feature" is simply C++'s more pedantic attitude > > to type coercions; if you must use a C++ compiler for C code, use an > > explicit cast. Better still, set up your project makefiles with the > > appropriate definitions for $(CC) and $(CXX), to use the correct GCC > > front end for each language, (and use $(CXX) for linking any mixed > > source application). > > > > Roman. > g++ --help emits this: Usage: g++ [options] file... Options: -pass-exit-codes Exit with highest error code from a phase --help Display this information . . . -E Preprocess only; do not compile, assemble or link -S Compile only; do not assemble or link -c Compile and assemble, but do not link -o <file> Place the output into <file> -x <language> Specify the language of the following input files Permissible languages include: c c++ assembler none 'none' means revert to the default behavior of guessing the language based on the file's extension So Roman, it looks as if the man page has a discrepancy with the command-line help. I have just tried -x (the 'none' mentioned above) but it too does not "guess" correctly that it is dealing with a c file. All of this wouldn't be an issue if were not using an IDE. The IDE can only use a common set of flags for all the files in the project. I think my best work around will be to compile the c++ module and make a library out of it, then link with the library from my c code. Will I run into c++ symbol naming issues if I use gcc to link to a c++ derived library? Clive. _________________________________________________________________ Hotmail: Free, trusted and rich email service. http://clk.atdmt.com/GBL/go/171222984/direct/01/ |