xia0ta0
V2EX  ›  C

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

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