跨平台开发,各种宏的定义
来源:互联网 发布:软件定制开发协议 编辑:程序博客网 时间:2024/06/06 05:00
gcc跨平台开发,各种宏的定义,_WIN32,__linux,__unix
Re: Cross platform code
From: Oleg Goldshmidt (pub_at_nonexisting.hamakor.org.il)
Date: Fri 04 Jul 2003 - 03:09:22 IDT
* Next message: Orna Agmon: "[HAIFUX LECTURE] from python import lecture, by Muli Ben-Yehuda"
* Previous message: Shachar Shemesh: "Re: Cross platform code"
* In reply to: Gilboa Davara: "Re: Cross platform code"
* Next in thread: Gilboa Davara: "Re: Cross platform code"
* Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
* Mail actions: [ respond to this message ] [ mail a new topic ]
Gilboa Davara <gilboa_at_xml-systems.com> writes:
> CPP/GCC/CC all define _WIN32 by default under all the environment I ever
> worked on. (which is pretty extensive.)
Really? Right now I am in an environment where several different
version of cpp and gcc don‘t define that. It seems to me that the
range of environments where gcc defines _WIN32 is pretty narrow.
To complement that, I have no idea what you mean by CPP or CC.
> By design, compilers running under Windows (be that Watcom, Borland or
> MCVC) must define _WINTVER, _WIN32 and M_IX86/M_ALPA/etc in-order to
> include the Winxxx.h files. (which are required to access any OS
> functions)
That‘s fine, this is exactly one platform that we have covered in the
passage above.
> So yes, these are compiler defined macros that can be relayed upon.
Yes, indeed. However, I know of no rule that says that, e.g., unix must
be defined for any of the unices or for Linux, as the snippet of your
earlier mail that follows below seems to imply.
On my RH7.3 gcc does define unix, __unix, __unix__, linux, __linux,
and __linux__. However, it is enough to use the -ansi option to
make unix and linux disappear. There you go.
None of the standard glibc or glibc-kernel headers (meaning
linux-specific headers exposed to applications programmers) uses unix,
__unix, or __unix__ (some applications do, but it‘s their
business). This tells me that gcc only uses those internally, and not
to access any library or system facilities. This means that there may
be compilers that will not define these macros and still work just
fine.
Gilboa Davara <gilboa_at_xml-systems.com> writes:
> Better yet:
>
> #ifdef unix
>
> // UNIX/Linux/*BSD.
>
> #endif
>
> #ifdef _WIN32
>
> // Window stuff
>
> #endif
>
> Both symbols are auto defined by the compiler.
Re: Cross platform code
From: Oleg Goldshmidt (pub_at_nonexisting.hamakor.org.il)
Date: Fri 04 Jul 2003 - 03:09:22 IDT
* Next message: Orna Agmon: "[HAIFUX LECTURE] from python import lecture, by Muli Ben-Yehuda"
* Previous message: Shachar Shemesh: "Re: Cross platform code"
* In reply to: Gilboa Davara: "Re: Cross platform code"
* Next in thread: Gilboa Davara: "Re: Cross platform code"
* Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
* Mail actions: [ respond to this message ] [ mail a new topic ]
Gilboa Davara <gilboa_at_xml-systems.com> writes:
> CPP/GCC/CC all define _WIN32 by default under all the environment I ever
> worked on. (which is pretty extensive.)
Really? Right now I am in an environment where several different
version of cpp and gcc don‘t define that. It seems to me that the
range of environments where gcc defines _WIN32 is pretty narrow.
To complement that, I have no idea what you mean by CPP or CC.
> By design, compilers running under Windows (be that Watcom, Borland or
> MCVC) must define _WINTVER, _WIN32 and M_IX86/M_ALPA/etc in-order to
> include the Winxxx.h files. (which are required to access any OS
> functions)
That‘s fine, this is exactly one platform that we have covered in the
passage above.
> So yes, these are compiler defined macros that can be relayed upon.
Yes, indeed. However, I know of no rule that says that, e.g., unix must
be defined for any of the unices or for Linux, as the snippet of your
earlier mail that follows below seems to imply.
On my RH7.3 gcc does define unix, __unix, __unix__, linux, __linux,
and __linux__. However, it is enough to use the -ansi option to
make unix and linux disappear. There you go.
None of the standard glibc or glibc-kernel headers (meaning
linux-specific headers exposed to applications programmers) uses unix,
__unix, or __unix__ (some applications do, but it‘s their
business). This tells me that gcc only uses those internally, and not
to access any library or system facilities. This means that there may
be compilers that will not define these macros and still work just
fine.
Gilboa Davara <gilboa_at_xml-systems.com> writes:
> Better yet:
>
> #ifdef unix
>
> // UNIX/Linux/*BSD.
>
> #endif
>
> #ifdef _WIN32
>
> // Window stuff
>
> #endif
>
> Both symbols are auto defined by the compiler.
- 跨平台开发,各种宏的定义
- 跨平台开发,各种宏的定义
- 应用软件开发平台的定义
- 罗列iOS开发中各种的宏定义
- 聊聊移动端跨平台开发的各种技术
- 聊聊移动端跨平台开发的各种技术
- 聊聊移动端跨平台开发的各种技术
- 聊聊移动端跨平台开发的各种技术
- 聊聊移动端跨平台开发的各种技术
- 跨平台宏定义
- 各种平台和标准库定义的数据类型一览
- 定义跨平台的数据类型
- App开发日报 2015-05-12 聊聊移动端跨平台开发的各种技术
- #ifdef 跨平台宏定义
- VC平台下各种字符串定义总结
- C中宏定义的各种作用
- 各种资源的定义
- 各种资源的定义
- MFC 的CList,CPtrList,CObList,CStringList 的用法
- 黑马程序员--IO流
- 利用dom4j 读取javabean生成XML和读取XML得到javabean对象(集合)
- ubuntu中的ubuntu软件中心
- MFC 的CList,CPtrList,CObList,CStringList 用法之CStringList
- 跨平台开发,各种宏的定义
- centos编译erlang需要的一些库
- hdu 4787 GRE Words Revenge (在线AC自动机)
- VC中类的强制性转化,通过派生来控制自己想要的类
- android 开发资源
- 利用DCC自动编译Delphi工程组文件
- 项目协作工具-JIRA使用笔记和相关资料
- error occurred during initialization of vm java/lang/noclassdeffounderror java/lang/object
- 使用CRectTracker类进行对象动态定位(一)