I want to building my codes but I can't
#include <iostream>
using namespace std;
class CTestData {
public:
explicit CTestData(int nParam) : m_nData(nParam) { }
operator int(void) { return m_nData; }
int GetData() const { return m_nData; }
void SetData(int nParam) { m_nData = nParam; }
private:
int main(int argc, char* argv[]) {
CTestData a(10);
cout << a.GetData() << endl;
cout << a << endl;
cout << (int)a << endl;
cout << static_cast<int>(a) << endl;
return 0;
}
}
Here's my errors.
warning: in-class initialization of non-static data member is a C++11 extension [-Wc++11-extensions] ld: can't link with a main executable file '/Users/a1/C++/.vscode/autotype' for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation
and this is my tasks.json
{
"version": "2.0.0",
"runner": "terminal",
"type": "shell",
"echoCommand": true,
"presentation" : { "reveal": "always" },
"tasks": [
//C++ 컴파일
{
"label": "build and compile for C++",
"type": "shell",
"command": "g++",
"args": [
"-g",
"-o",
"-std=c++14",
"${fileDirname}/${fileBasenameNoExtension}",
"${file}"
],
"group": {
"kind":"build",
"isDefault": true },
//컴파일시 에러를 편집기에 반영
//참고: https://code.visualstudio.com/docs/editor/tasks#_defining-a-problem-matcher
"problemMatcher": {
"fileLocation": [
"relative",
"${workspaceRoot}"
],
"pattern": {
// The regular expression.
//Example to match: helloWorld.c:5:3: warning: implicit declaration of function 'prinft'
"regexp": "^(.*):(\\d+):(\\d+):\\s+(warning error):\\s+(.*)$",
"file": 1,
"line": 2,
"column": 3,
"severity": 4,
"message": 5
}
}
},
//C 컴파일
{
"label": "save and compile for C",
"command": "gcc",
"args": [
"${file}",
"-o",
"${fileDirname}/${fileBasenameNoExtension}"
],
"group": {
"kind":"build",
"isDefault": true},
//컴파일시 에러를 편집기에 반영
//참고: https://code.visualstudio.com/docs/editor/tasks#_defining-a-problem-matcher
"problemMatcher": {
"fileLocation": [
"relative",
"${workspaceRoot}"
],
"pattern": {
// The regular expression.
//Example to match: helloWorld.c:5:3: warning: implicit declaration of function 'prinft'
"regexp": "^(.*):(\\d+):(\\d+):\\s+(warning error):\\s+(.*)$",
"file": 1,
"line": 2,
"column": 3,
"severity": 4,
"message": 5
}
}
},
// 바이너리 실행(Ubuntu)
{
"label": "execute",
"command": "cd ${fileDirname} && ./${fileBasenameNoExtension}",
"group": "test"
}
]
}
and this is my launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "(lldb) Launch",
"type": "cppdbg",
"request": "launch",
"program": "enter program name, for example ${workspaceFolder}/a.out",
"miDebuggerPath": "/Users/a1/C++/cpp.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": true,
"MIMode": "lldb"
}
]
}
this is my cpp_properties.json help me PLEASE :<
{
"configurations": [
{
"name": "Mac",
"includePath": [
"${workspaceFolder}"
],
"defines": ["_DEBUG", "UNICODE"],
"macFrameworkPath": [
"/System/Library/Frameworks",
"/Library/Frameworks"
],
"compilerPath": "/Users/a1/C++/first.cpp",
"cStandard": "c11",
"cppStandard": "c++17",
"intelliSenseMode": "clang-x64"
}
],
"browse": {
"path": [
"${workspaceFolder}","/Users/a1/C++/first.cpp"
],
"limitSymbolsToIncludedHeaders": true,
"databaseFilename": ""
},
"version": 4
}
Aucun commentaire:
Enregistrer un commentaire