This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
int main(){ | |
std::cout << "Hello World"; | |
return 0; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
g++ hello.cpp -o hello | |
./hello | |
Hello World |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int main(){ | |
int a = 1; | |
return 0; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cpp_tutorial# g++ warning_example.cpp -Wall -o a | |
warning_example.cpp: In function ‘int main()’: | |
warning_example.cpp:2:9: warning: unused variable ‘a’ [-Wunused-variable] | |
int a = 1; | |
^ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int main(){ | |
int array[100]; | |
return array[1]; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cpp_tutorial# g++ warning_example.cpp -Wuninitialized -o a -Werror | |
warning_example.cpp: In function ‘int main()’: | |
warning_example.cpp:4:19: error: ‘array[1]’ is used uninitialized in this function [-Werror=uninitialized] | |
return array[1]; | |
^ | |
cc1plus: all warnings being treated as errors |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#ifndef SIZE_ARRAY | |
#define SIZE_ARRAY 4 | |
#endif | |
int main(){ | |
int array[SIZE_ARRAY] = {0}; | |
std::cout << "num of elements: " << sizeof(array)/sizeof(array[0]) << "\n"; | |
return 0; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "vars.h" | |
int main(){ | |
return 0; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int a = 1; | |
int foo(){ | |
return 2; | |
} | |
int main(){ | |
return 0; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
g++ -E example.cpp -o _preprocess.out |
OlderNewer