CMake Error at CMakeLists.txt:3 (project):
No CMAKE_CXX_COMPILER could be found.
Tell CMake where to find the compiler by setting either the environment
variable "CXX" or the CMake cache entry CMAKE_CXX_COMPILER to the full path
to the compiler, or to the compiler name if it is in the PATH.
-- Configuring incomplete, errors occurred!
原因是:cmake 的project() 命令在没有指定 LANGUAGES 选项时,默认是C和CXX(注意cmake 3.0之前的版本不支持LANGUAGES 关键字),CXX编译时需要指定 g++编译器。
mkdir build
cd build
cmake ../
make
# 执行
./conditionTest01
123.45
found an integer, = 123
found a dot
found an integer, = 45
"expect-floats" 123.45
"" found a float,=123.450000
123
found an integer, = 123
执行结果如下图所示:
独占模式%x
使用独占模式:%x expect
编译执行:
└─# ./conditionTest01
123.456
found an integer, = 123
found a dot
found an integer, = 456
"expect-floats"
""123.45
found a float,=123.450000
123456
123456
789
789
Stack stack;
// 初始化
initStack(&stack);
int a = 20;
int b = 30;
int c = 40;
int *ptr_1 = &a;
int *ptr_2 = &b;
int *ptr_3 = &c;
push(&stack, ptr_1);
push(&stack, ptr_2);
push(&stack, ptr_3);
int *ptr = NULL;
for (int i = 0; i < 3; i++)
{
ptr = (int *)pop(&stack);
printf("Popped %d\n", *ptr);
}