V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
xia0ta0
V2EX  ›  C

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

  •  
  •   xia0ta0 · Jul 2, 2014 · 2241 views
    This topic created in 4330 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   ·   3018 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 29ms · UTC 08:28 · PVG 16:28 · LAX 01:28 · JFK 04:28
    ♥ Do have faith in what you're doing.