Peng Yu | 15 Jul 23:56

POSIX in g++

Hi,

There is an options -ansi to make g++ ANSI compatible. I'm wondering
if there is an option to make g++ POSIX compatible. Or g++ is already
POSIX compatible without an option?

Thanks,
Peng

Ian Lance Taylor | 16 Jul 00:57

Re: POSIX in g++

"Peng Yu" <pengyu.ut <at> gmail.com> writes:

> There is an options -ansi to make g++ ANSI compatible. I'm wondering
> if there is an option to make g++ POSIX compatible. Or g++ is already
> POSIX compatible without an option?

POSIX itself specifies features macros which you may define to compile
your source code in a strict POSIX environment.  These are
_POSIX_SOURCE and _POSIX_C_SOURCE.  These affect the header files
rather than the libraries.  To get a strict POSIX compiler, use those
in conjunction with -ansi or -std.

Ian

Peng Yu | 16 Jul 01:46

Re: POSIX in g++

On Tue, Jul 15, 2008 at 5:57 PM, Ian Lance Taylor <iant <at> google.com> wrote:
> "Peng Yu" <pengyu.ut <at> gmail.com> writes:
>
>> There is an options -ansi to make g++ ANSI compatible. I'm wondering
>> if there is an option to make g++ POSIX compatible. Or g++ is already
>> POSIX compatible without an option?
>
> POSIX itself specifies features macros which you may define to compile
> your source code in a strict POSIX environment.  These are
> _POSIX_SOURCE and _POSIX_C_SOURCE.  These affect the header files
> rather than the libraries.  To get a strict POSIX compiler, use those
> in conjunction with -ansi or -std.
>
> Ian
>

Peng Yu | 16 Jul 01:49

Re: POSIX in g++

On Tue, Jul 15, 2008 at 5:57 PM, Ian Lance Taylor <iant <at> google.com> wrote:
> "Peng Yu" <pengyu.ut <at> gmail.com> writes:
>
>> There is an options -ansi to make g++ ANSI compatible. I'm wondering
>> if there is an option to make g++ POSIX compatible. Or g++ is already
>> POSIX compatible without an option?
>
> POSIX itself specifies features macros which you may define to compile
> your source code in a strict POSIX environment.  These are
> _POSIX_SOURCE and _POSIX_C_SOURCE.  These affect the header files
> rather than the libraries.  To get a strict POSIX compiler, use those
> in conjunction with -ansi or -std.

Hi Ian,

Isn't ANSI C++ a subset of POSIX C++. Why do I need to specify
_POSIX_SOURCE,  _POSIX_C_SOURCE and -ansi?

Would you please let me know what is the difference between the option
-ansi and -std?

Thanks,
Peng

Ian Lance Taylor | 16 Jul 03:09

Re: POSIX in g++

"Peng Yu" <pengyu.ut <at> gmail.com> writes:

I should have said in reply to your last message: this is the wrong
mailing list for this question.  Please take any followups to
gcc-help <at> gcc.gnu.org.  Thanks.

> Isn't ANSI C++ a subset of POSIX C++. Why do I need to specify
> _POSIX_SOURCE,  _POSIX_C_SOURCE and -ansi?

ANSI C is a subset of POSIX C (as far as I know C++ is not a part of
POSIX).  Using -ansi restricts you to ANSI C.  Adding the POSIX
defines tells the library to declare POSIX functions in the POSIX
header files.

> Would you please let me know what is the difference between the option
> -ansi and -std?

Please read the fine manual.

Ian


Gmane