I faced something stranger, I ask for help from good people. I use windows 10, g++ compiler, visual studio code. i tried moving g++.exe itself to another directory, tried run with --verbose and -W, it doesn't help. Im trying to make almost empty project:
#include <stddef.h>
#include <windows.h>
#include "glut.h"
int main(){
return 0;
}
glut files version 3.7.6, gl.h and glu.h from windows SDK 10.0.26100.0 for windows 10.
my tasks.json:
{
"tasks": [
{
"type": "cppbuild",
"label": "C/C++: g++.exe build active file",
"command": "c://temporarygcc//ucrt64//bin//g++.exe",
"args": [
"-fdiagnostics-color=always",
"-g",
"${file}",
"${workspaceFolder}//glut32.lib",
"${workspaceFolder}//glut32.dll",
"${workspaceFolder}//glut.def",
"${workspaceFolder}//glut.h",
"-o",
"${fileDirname}\\${fileBasenameNoExtension}.exe"
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "Task generated by Debugger."
}
],
"version": "2.0.0"
}
First error:
Starting build...
cmd /c chcp 65001>nul && c://temporarygcc//ucrt64//bin//g++.exe -fdiagnostics-color=always -g C:\Users\leonid\Desktop\vsccp\program.cpp C:\Users\leonid\Desktop\vsccp//glut32.lib C:\Users\leonid\Desktop\vsccp//glut32.dll C:\Users\leonid\Desktop\vsccp//glut.def C:\Users\leonid\Desktop\vsccp//glut.h -o C:\Users\leonid\Desktop\vsccp\program.exe
C:/Users/leonid/Desktop/vsccp/glut.h:50:24: error: redeclaration of C++ built-in type 'wchar_t' [-fpermissive]
50 | typedef unsigned short wchar_t;
| ^~~~~~~
Build finished with error(s).
then I rename wchar_t -> wchar_tt
what i get:
Starting build...
cmd /c chcp 65001>nul && c://temporarygcc//ucrt64//bin//g++.exe -fdiagnostics-color=always -g C:\Users\leonid\Desktop\vsccp\program.cpp C:\Users\leonid\Desktop\vsccp//glut32.lib C:\Users\leonid\Desktop\vsccp//glut32.dll C:\Users\leonid\Desktop\vsccp//glut.def C:\Users\leonid\Desktop\vsccp//glut.h -o C:\Users\leonid\Desktop\vsccp\program.exe
collect2.exe: error: ld returned 5 exit status
Build finished with error(s).
if I run it with gcc program.cpp glut.h glut32.lib glut32.dll --verbose
i get this:
C:/msys64/ucrt64/include/GL/glu.h:25:7: error: unknown type name 'wchar_t'
25 | const wchar_t *APIENTRY gluErrorUnicodeStringEXT(GLenum errCode);
| ^~~~~~~
C:/msys64/ucrt64/include/GL/glu.h:1:1: note: 'wchar_t' is defined in header '<stddef.h>'; this is probably fixable by adding '#include <stddef.h>'
+++ |+#include <stddef.h>
1 | /**
than I go right into C:/msys64/ucrt64/include/GL/glu.h
and add #include <stddef.h>
to the first line of file. Run again and get:
C:/msys64/ucrt64/include/GL/glu.h:27:7: error: unknown type name 'wchar_t'
27 | const wchar_t *APIENTRY gluErrorUnicodeStringEXT(GLenum errCode);
| ^~~~~~~
C:/msys64/ucrt64/include/GL/glu.h:7:1: note: 'wchar_t' is defined in header '<stddef.h>'; this is probably fixable by adding '#include <stddef.h>'
6 | #include <stddef.h>
+++ |+#include <stddef.h>
7 |
what is my next move?
UPD:
when I use cl.exe instead of g++.exe , it ignores wchar_t problem, and compiles program without single error. What why ?