簡體   English   中英

LLVM預處理器顯然不支持##運算符?

[英]LLVM preprocessor apparently does not support ## operator?

顯然,clang / llvc cpp命令不支持##運算符

編碼

sbo@linux:$ more x.c 
#define foo(a,b) (a ## b)

foo(one,two)

在OSX 10.8上我得到

osx108 stefanoborini$ cpp --version
Apple LLVM version 5.0 (clang-500.2.79) (based on LLVM 3.3svn)
Target: x86_64-apple-darwin12.5.0
Thread model: posix
osx108 stefanoborini$ cpp x.c 
# 1 "x.c"
# 1 "<built-in>" 1
# 1 "<built-in>" 3
# 161 "<built-in>" 3
# 1 "<command line>" 1
# 1 "<built-in>" 2
# 1 "x.c" 2


(one ## two)

在Linux上我得到

sbo@linux:$ cpp --version
cpp (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3
Copyright (C) 2011 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

sbo@linux:$ cpp x.c 
# 1 "x.c"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "x.c"


(onetwo)

是否有cpp開關允許在llvm中使用##運算符?

clang的cpp傳統cpp模式下進行預處理,其中stringification #和token-pasting ## 沒有意義

$ cpp -### 1.c
Apple LLVM version 5.0 (clang-500.2.79) (based on LLVM 3.3svn)
Target: x86_64-apple-darwin13.0.0
Thread model: posix
 ...[snipped]... "-traditional-cpp" "-o" "-" "-x" "c" "1.c"

必須使用cpp接口,還是可以使用clang -E代替?

$ clang -E 1.c
# 1 "1.c"
# 1 "<built-in>" 1
# 1 "<built-in>" 3
# 162 "<built-in>" 3
# 1 "<command line>" 1
# 1 "<built-in>" 2
# 1 "1.c" 2


onetwo

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM