Kali ini saya ingin share mangenai Porting source code c++ ke windows. Hal ini diperlukan apabila source code yang anda buat di linux di-compile lagi di windows.
Berikut ini adalah compile error dan solusinya:
- Compile error:
error C3861: 'assert': identifier not found
Solution:#ifdef WIN32 #include <assert> #endif
- Compile error:
fatal error C1083: Cannot open include file: 'values.h': No such file or directory
Solution:
#ifdef WIN32 #include <limits.h> #else #include <values.h> #endif
- Compile error:
error C3861: 'time': identifier not found
Solution:
#ifdef WIN32 #include <ctime> #endif
- Compile error:
error C2065: 'M_PI' : undeclared identifier
Solution:
#ifdef WIN32 #define _USE_MATH_DEFINES #include <math.h> using namespace std; #endif
- Compile error:
GL/gl.h(1152) : error C2144: syntax error : 'void' should be preceded by ';' GL/gl.h(1152) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int GL/gl.h(1152) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int GL/gl.h(1153) : error C2086: 'int APIENTRY' : redefinition
Solution: add <windows.h> above <Gl/gl.h>
#ifdef WIN32 #include <windows.h> #endif #include <Gl/gl.h>
- Compile error:
error C3861: 'fmax': identifier not found
Solution:
#if defined(_WIN32) || defined(_WIN64) #define fmax max #define fmin min #pragma warning (disable:4996) #define snprintf sprintf_s #endif;
Semoga hal ini dapat berguna. Tq.
Advertisement