this's my cpp code:
#pragma once
#include <cstdio>
int main(char** args, int size)
{
printf("aaaaa\n");
return 1;
}
this's my CMakeLists.txt
cmake_minimum_required(VERSION 3.5)
set(PROJECT_ROOT_PATH "./")
add_executable(app ${PROJECT_ROOT_PATH}/app.c)
my steps running command is following:
cmake -G "NMake Makefiles" ./
nmake
when I run nmake, there are many errors like this:
D:\Program_Filesx86\Microsoft Visual Studio 14.0\VC\include\cstdio(36): error C2054: expected '(' to follow 'using' [E:\cmake-test\app.vcxproj]
D:\Program_Filesx86\Microsoft Visual Studio 14.0\VC\include\cstdio(36): error C2061: syntax error: identifier 'using' [E:\cmake-test\app.vcxproj]
if keep a empty function there:
#pragma once
int main(char** args, int size)
{
return 1;
}
nmake would works righ and output an executable file: app.exe
is the problem that I didn't specify includes and libraries of windows SDK? if so, how can I configurate them?
File cstdio
might contain C++ specific stuff. C++ is a superset of a subset of C, so not every C++ code is valid C.
CMake compiles your .c
file as C, thus syntax errors.
In your case the source of the error is C++ using
statements that do not exist in C programming language.
To fix the problem either:
#include <stdio.h>
(and compile as C as it was) or
.cpp
(so it would be compiled as C++)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.