我的问题与
this
线程。
这是密码
#include <stdio.h>
int main(int argc, char *argv[printf("Hello, world!\n")]) {}
我不小心把它保存为
*.cpp
文件并试图用
g++
. 但我得到了一个错误和警告。
error: expected ',' or '...' before 'argv'
warning: second argument of 'int main(int, char*)' should be 'char **
'
我知道上面的代码不是标准的C++(数组的大小必须是C++中的常量表达式)。
我一直在想
G+
支持可变长度数组作为扩展。我哪里错了?
P.S:上面的代码是用clang编译的++
C:\Users\SUPER USER\Desktop>type check.cpp
#include <stdio.h>
int main(int argc, char *argv[printf("Hello, world!\n")]) {}
C:\Users\SUPER USER\Desktop>clang++ check.cpp
C:\Users\SUPER USER\Desktop>