6
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

【Xcode】コンパイル時に64bitかどうか判定する

Last updated at Posted at 2017-07-11

はじめに

Xcodeコンパイル時に64bitか32bitで処理を分けたいケースがあったので備忘録としてまとめました。

サンプルコード

/* Swift */
#if (arch(arm64) || arch(x86_64))
    print("64bit cpu")
#else
    print("32bit cpu")
#endif
/* Objective-C */
#if __LP64__
    NSLog(@"64bit cpu");
#else
    NSLog(@"32bit cpu");
#endif
/* C++ */
#if __LP64__
    printf("64bit cpu\n");
#else
    printf("32bit cpu\n");
#endif

環境

Xcode Version 8.3.3 (8E3004b)

6
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?