Gl3w compilation errors: invalid conversion from 'PROC ... to void*' - windows

Setting up gl3w in my computer: 2 errors that I have no idea how to resolve are being thrown:
Function that's built by Gl3w script which has the errors:
static void *get_proc(const char *proc) - line 19
{
void *res;
res = wglGetProcAddress(proc); - line 23, first error
if (!res)
res = GetProcAddress(libgl, proc); - line 25, second error
return res;
}
Build errors:
||=== LearnOPG, Debug ===|
C:\CodeBlocks\LearnOPG\gl3w.c||In function 'void* get_proc(const char*)':|
C:\CodeBlocks\LearnOPG\gl3w.c|23|error: invalid conversion from 'PROC {aka int (__attribute__((__stdcall__)) *)()}' to 'void*' [-fpermissive]|
C:\CodeBlocks\LearnOPG\gl3w.c|25|error: invalid conversion from 'FARPROC {aka int (__attribute__((__stdcall__)) *)()}' to 'void*' [-fpermissive]|
||=== Build finished: 2 errors, 0 warnings (0 minutes, 0 seconds) ===|

Some compilers/platforms are less picky than others. Implicitly converting function pointers to void* and back is not guaranteed to be possible by C or C++. But GL3W's code expects it to work; obviously, it was not tested with more strict compilers/platforms.
You should probably file a bug report on it with the GL3W people. Granted, it doesn't seem to be being actively worked on, but they might fix it.

Related

Failed to compile OpenVDB on Windows(VS2017)

I tried to compile OpenVDB on Windows11(VS2017), but confusing error occurs:
Error C2676 Binary '<': 'const _Ty' does not define the operator or a conversion to a type that can be received by a predefined operator openvdb_shared
Error C2056 invalid expressions
Error C2088 invalid for class
It points to <algorithm.h> file, line 5386: "_NOEXCEPT_COND(_NOEXCEPT_OPER(_Left < _Right))".
#pragma warning(push)
#pragma warning(disable: 28285) // (syntax error in SAL annotation, occurs when _Ty is not an integral type)
template<class _Ty>
_Post_equal_to_(_Left < _Right ? _Right : _Left)
_NODISCARD constexpr const _Ty& (max)(const _Ty& _Left, const _Ty& _Right)
_NOEXCEPT_COND(_NOEXCEPT_OPER(_Left < _Right))
{ // return larger of _Left and _Right
if (_Left < _Right)
{
_STL_ASSERT(!(_Right < _Left), "invalid comparator");
return (_Right);
}
return (_Left);
}
and anothor fatal error:
fatal error LNK1104: can not open file “....\openvdb\openvdb\Debug\openvdb.lib”
I download OpenVDB source code and dependencies by git and vcpkg following the manual OpenVDB. I have no idea about how to fix those problems. Any suggestions or solution would be greatly appreciated!!!

How to fix cgo error caused by race flag?

How can I fix this?
STDERR: # runtime/cgo
gcc_libinit_windows.c: In function ‘_cgo_beginthread’:
gcc_libinit_windows.c:136:27: error: implicit declaration of function ‘_beginthread’; did you mean ‘_cgo_beginthread’? [-Werror=implicit-function-declaration]
136 | thandle = _beginthread(func, 0, arg);
| ^~~~~~~~~~~~
| _cgo_beginthread
cc1: all warnings being treated as errors
make[1]: *** [Makefile:15: unit] Error 2
https://go.dev/src/runtime/cgo/gcc_libinit_windows.c
It turned out that it was some issue with cygwin compiler, after switching to mingw (https://github.com/niXman/mingw-builds-binaries/releases) everything works fine.
see the file go1.19.1\src\runtime\cgo\libcgo_windows.h
// Call _beginthread, aborting on failure.
void _cgo_beginthread(void (*func)(void*), void* arg);
so...
delete function _cgo_beginthread in gcc_libinit_windows.c will fix it

What Else Do I Need to Do to Run the lwIP Simulation in Omnet++?

I am still trying to run the following simulation on Omnet 5.6.1 (using INET 4.2.5) inet/examples/inet/nclients/omnetpp.ini.
When I build INET without TCP (lwIP) checkbox checked in the Project Features window I get a clean build. If I check the checkbox I get the following 26 errors:
inet/transportlayer/tcp_lwip/lwip/include/ipv4\lwip/inet.h:47:9: error: expected ';' at end of declaration list
u32_t s_addr;
inet/transportlayer/tcp_lwip/lwip/include/ipv4\lwip/inet.h:69:7: error: functions that differ only in their return type cannot be overloaded
u32_t inet_addr(const char *cp);
inet/transportlayer/tcp_lwip/lwip/include/ipv4\lwip/inet.h:69:7: warning: 'inet_addr' redeclared without 'dllimport' attribute: previous 'dllimport' ignored [-Winconsistent-dllimport]
u32_t inet_addr(const char *cp);
inet/transportlayer/tcp_lwip/lwip/include/ipv4\lwip/inet.h:47:9: error: expected ';' at end of declaration list
u32_t s_addr;
inet/transportlayer/tcp_lwip/lwip/include/ipv4\lwip/inet.h:69:7: error: functions that differ only in their return type cannot be overloaded
u32_t inet_addr(const char *cp);
inet/transportlayer/tcp_lwip/lwip/include/ipv4\lwip/inet.h:69:7: warning: 'inet_addr' redeclared without 'dllimport' attribute: previous 'dllimport' ignored [-Winconsistent-dllimport]
u32_t inet_addr(const char *cp);
inet/transportlayer/tcp_lwip/lwip/include/ipv4\lwip/inet.h:71:7: error: conflicting types for 'inet_ntoa'
char *inet_ntoa(struct in_addr addr); /* returns ptr to static buffer; not reentrant! */
inet/transportlayer/tcp_lwip/lwip/include/ipv4\lwip/inet.h:71:7: warning: 'inet_ntoa' redeclared without 'dllimport' attribute: previous 'dllimport' ignored [-Winconsistent-dllimport]
char *inet_ntoa(struct in_addr addr); /* returns ptr to static buffer; not reentrant! */
inet/transportlayer/tcp_lwip/lwip/include/ipv4\lwip/inet.h:47:9: error: expected ';' at end of declaration list
u32_t s_addr;
inet/transportlayer/tcp_lwip/lwip/include/ipv4\lwip/inet.h:71:7: error: conflicting types for 'inet_ntoa'
char *inet_ntoa(struct in_addr addr); /* returns ptr to static buffer; not reentrant! */
inet/transportlayer/tcp_lwip/lwip/include/ipv4\lwip/inet.h:69:7: error: functions that differ only in their return type cannot be overloaded
u32_t inet_addr(const char *cp);
::38: C:\OMNET\omnetpp561\omnetpp-5.6.1\tools\win64\mingw64\x86_64-w64-mingw32\include\winnt.h WINSOCK_API_LINKAGE unsigned __LONG32 WSAAPI inet_addr(const char *cp);:
C:\OMNET\omnetpp561\omnetpp-5.6.1\tools\win64\mingw64\x86_64-w64-mingw32\include\winnt.h:147:37: WINSOCK_API_LINKAGE u_short WSAAPI htons(u_short hostshort);52
^inet/transportlayer/tcp_lwip/lwip/include/ipv4\lwip/inet.h
:111:7: error: functions that differ only in their return type cannot be overloaded
u32_t htonl(u32_t x);
In file included from inet/transportlayer/tcp_lwip/lwip/include\lwip/lwip_tcp.hC:\OMNET\omnetpp561\omnetpp-5.6.1\tools\win64\mingw64\x86_64-w64-mingw32\include\winnt.hinet/transportlayer/tcp_lwip/lwip/include\lwip/lwip_tcp.h::52: WINSOCK_API_LINKAGE unsigned __LONG32 WSAAPI inet_addr(const char *cp);147:
:In file included from
37 ^inet/transportlayer/tcp_lwip/lwip/include/ipv4\lwip/lwip_ip.h
inet/transportlayer/tcp_lwip/lwip/include/ipv4\lwip/inet.h:112:7: error: functions that differ only in their return type cannot be overloaded
u32_t ntohl(u32_t x);
inet/transportlayer/tcp_lwip/lwip/include/ipv4\lwip/inet.h:71:7: error: conflicting types for 'inet_ntoa'
char *inet_ntoa(struct in_addr addr); /* returns ptr to static buffer; not reentrant! */
inet/transportlayer/tcp_lwip/lwip/include/ipv4\lwip/inet.h:111:7: error: functions that differ only in their return type cannot be overloaded
u32_t htonl(u32_t x);
In file included from inet/transportlayer/tcp_lwip/lwip/include/ipv4\lwip/lwip_ip.h::112:7: error: functions that differ only in their return type cannot be overloaded
u32_t ntohl(u32_t x);
inet/transportlayer/tcp_lwip/lwip/include/ipv4\lwip/inet.h:112:7: error: functions that differ only in their return type cannot be overloaded
u32_t ntohl(u32_t x);
119:9: C:\OMNET\omnetpp561\omnetpp-5.6.1\tools\win64\mingw64\x86_64-w64-mingw32\include\winsock2.hwarning:: 'IN_CLASSB_HOST' macro redefined [-Wmacro-redefined]
#define IN_CLASSB_HOST (0xffffffff & ~IN_CLASSB_NET)
inet/transportlayer/tcp_lwip/lwip/include/ipv4\lwip/inet.h:111:7: error: functions that differ only in their return type cannot be overloaded
u32_t htonl(u32_t x);
In file included from inet/transportlayer/tcp_lwip/lwip/include/ipv4\lwip/ip_addr.h:37:
inet/transportlayer/tcp_lwip/lwip/include/ipv4\lwip/inet.h:112:7: error: functions that differ only in their return type cannot be overloaded
u32_t ntohl(u32_t x);
9 warnings and 5 errors generated.
9 warnings and 5 errors generated.
make[1]: *** [Makefile:1762: ../out/clang-debug/src/inet/transportlayer/tcp_lwip/LwipTcpLayer.o] Error 1
make[1]: *** Waiting for unfinished jobs....
make[1]: *** [Makefile:1762: ../out/clang-debug/src/inet/transportlayer/tcp_lwip/lwip/core/memp.o] Error 1
9 warnings and 5 errors generated.
make[1]: *** [Makefile:1762: ../out/clang-debug/src/inet/transportlayer/tcp_lwip/TcpLwipConnection.o] Error 1
9 warnings and 5 errors generated.
make[1]: *** [Makefile:1762: ../out/clang-debug/src/inet/transportlayer/tcp_lwip/TcpLwip.o] Error 1
make[1]: Leaving directory '/c/OMNET/omnetpp561/inet4/src'
make: *** [Makefile:7: all] Error 2
"make MODE=debug -j4 all" terminated with exit code 2. Build might be incomplete.
When I try to run the simulation I get the following error:
<!> Error: Cannot load library '../../../src//libINET.dll': The specified module could not be found
End.
Simulation terminated with exit code: 1
Working directory: C:/OMNET/omnetpp561/inet4/examples/inet/nclients
Command line: ../../../../../../Pakhuis/Akademie/MEng/Thesis/Simulasie/WorkSpaces/ThesisSimulations/ThesisSimulations/src/ThesisSimulations.exe -m -n ../../../src;../..;../../../tutorials;../../../showcases --image-path=../../../images -l ../../../src/INET omnetpp.ini
<!> Error: Cannot load library '../../../src//libINET.dll': The specified module could not be found
End.
Simulation terminated with exit code: 1
Working directory: C:/OMNET/omnetpp561/inet4/examples/inet/nclients
Command line: ../../../../../../Pakhuis/Akademie/MEng/Thesis/Simulasie/WorkSpaces/ThesisSimulations/ThesisSimulations/src/ThesisSimulations.exe -m -n ../../../src;../..;../../../tutorials;../../../showcases --image-path=../../../images -l ../../../src/INET omnetpp.ini
Environment variables:
PATH=;C:/OMNET/omnetpp561/inet4/src;C:\OMNET\omnetpp561\omnetpp-5.6.1\bin;C:\OMNET\omnetpp561\omnetpp-5.6.1\tools\win64\mingw64\bin;C:\OMNET\omnetpp561\omnetpp-5.6.1\tools\win64\usr\bin;;C:/OMNET/omnetpp561/omnetpp-5.6.1/ide/jre/bin/server;C:/OMNET/omnetpp561/omnetpp-5.6.1/ide/jre/bin;C:/OMNET/omnetpp561/omnetpp-5.6.1/ide/jre/lib/amd64;.;C:\OMNET\omnetpp561\omnetpp-5.6.1\bin;C:\OMNET\omnetpp561\omnetpp-5.6.1\tools\win64\mingw64\bin;C:\OMNET\omnetpp561\omnetpp-5.6.1\tools\win64\usr\local\bin;C:\OMNET\omnetpp561\omnetpp-5.6.1\tools\win64\usr\bin;C:\OMNET\omnetpp561\omnetpp-5.6.1\tools\win64\usr\bin;C:\Windows\System32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\OMNET\omnetpp561\omnetpp-5.6.1\tools\win64\usr\bin\site_perl;C:\OMNET\omnetpp561\omnetpp-5.6.1\tools\win64\usr\bin\vendor_perl;C:\OMNET\omnetpp561\omnetpp-5.6.1\tools\win64\usr\bin\core_perl;C:\OMNET\omnetpp561\omnetpp-5.6.1;
OMNETPP_ROOT=C:/OMNET/omnetpp561/omnetpp-5.6.1/
OMNETPP_IMAGE_PATH=C:\OMNET\omnetpp561\omnetpp-5.6.1\images
I have tried re installing OMNET++ and using other INET versions. I also tried using OMNET 4.2.2 with no success.
Can someone please advise what I should do?
Kind regards
Benjamin
The TCP_LWIP feature works only on Linux. On Windows, certain functions are clashing with the windows winsock2 library. (That's why the feature is disabled by default)

How to pass time_t by reference into a function

I have a function definition like this:
double getPriceTimeByPtr(const StrategyParams* ptr, const int applied_price, const int timeframe, const int shift, const int shift_delta, const bool normalized, time_t &time);
but when I compile this code it errors just before the &time part so clearly there is a problem passing a time_t object by reference.
How do I fix this please?
I recently added the time_t parameter to the function and the error occurred since then.
Here's the errors generated:
Severity Code Description Project File Line Suppression
State
Error C2143 syntax error: missing ')' before '&'
Error C2143 syntax error: missing '{' before '&'
Error C2059 syntax error: '&'
Error C2059 syntax error: ')'
The syntax seems correct to me but the compiler doesn't like it.
The project that was failing was defined as a C project which was then trying to call a C++ function by reference. C can't us by reference so was failing. Changing the time parameters to pointers worked.

In Keil MDK-ARM C++11 *default NAN value* for member and function's parameter generates strange errors

Have you ever faced with yet another Keil's "feature" when next code
#include <cmath>
struct AB {
float f=NAN;
float foo(float a=NAN);
};
generates next build output:
compiling main.cpp...
..\..\src\main.cpp(24): error: #65: expected a ";"
float foo(float a=
AN);
..\..\src\main.cpp(24): error: #109: expression preceding parentheses of apparent call must have (pointer-to-) function type
float foo(float a=NAN);
..\..\src\main.cpp(24): error: #18: expected a ")"
float foo(float a=NAN);
..\..\src\main.cpp(24): error: #18: expected a ")"
float foo(float a=NAN);
..\..\src\main.cpp(23): error: #65: expected a ";"
float f=NAN;
..\..\src\main.cpp: 0 warnings, 5 errors`
For me it looks like bug. I have never met same nuisance in GCC and other compilers.
5 errors in 2 rows. Fantastic. WTF? MDK-ARM cannot resolve NAN.
This could be fixed with next row:
#define __ESCAPE__(__x) (__x)
Better make it for only this "cool" compiler:
#ifdef __CC_ARM
#define __ESCAPE__(__x) (__x)
#endif
Another solution (not sure, but it could be compiler's extension):
float f = 0f_7FC00000;

Resources