xia0ta0
V2EX  ›  C

C 语言怎样在预编译期确定系统是 32 位还是 64 位的?

  •  
  •   xia0ta0 · Jul 2, 2014 · 2610 views
    This topic created in 4506 days ago, the information mentioned may be changed or developed.
    只能使用各个编译器提供的宏吗?比如GCC的 __LP64__
    4 replies  •  2014-07-02 11:25:24 +08:00
    missdeer
    missdeer
    Jul 2, 2014
    1
    你都说是在预编译期了,不用宏用什么
    madeye
    madeye
    Jul 2, 2014❤️1
    2
    配合 configure 脚本或者 Makefile
    xia0ta0
    xia0ta0
    OP
    Jul 2, 2014
    3
    @madeye 多谢,我在Makefile里试试
    xia0ta0
    xia0ta0
    OP
    Jul 2, 2014
    4
    已解决
    在Makefile定义ARCH = $(shell getconf LONG_BIT) ,然后CFLAGS += -D向代码传递宏定义就可以了
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   1562 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 23:06 · PVG 07:06 · LAX 15:06 · JFK 18:06
    ♥ Do have faith in what you're doing.