I am trying to build python netifaces for windows. I am using microsoft visual c++ express 2010 edition. When I run the command python setup.py install I get the following log and errors:
running install
running bdist_egg
running egg_info
writing netifaces.egg-info\PKG-INFO
writing top-level names to netifaces.egg-info\top_level.txt
writing dependency_links to netifaces.egg-info\dependency_links.txt
reading manifest file 'netifaces.egg-info\SOURCES.txt'
writing manifest file 'netifaces.egg-info\SOURCES.txt'
installing library code to build\bdist.win32\egg
running install_lib
running build_ext
building 'netifaces' extension
c:\Program Files\Microsoft Visual Studio 10.0\VC\BIN\cl.exe /c /nologo /Ox /MD /
W3 /GS- /DNDEBUG -DWIN32=1 -DNETIFACES_VERSION=0.8 -Ic:\python27\include -Ic:\py
thon27\PC /Tcnetifaces.c /Fobuild\temp.win32-2.7\Release\netifaces.obj
netifaces.c
netifaces.c(410) : error C2275: 'PyObject' : illegal use of this type as an expr
ession
c:\python27\include\object.h(108) : see declaration of 'PyObject'
netifaces.c(411) : error C2275: 'PyObject' : illegal use of this type as an expr
ession
c:\python27\include\object.h(108) : see declaration of 'PyObject'
netifaces.c(720) : error C2275: 'PyObject' : illegal use of this type as an expr
ession
c:\python27\include\object.h(108) : see declaration of 'PyObject'
netifaces.c(720) : error C2065: 'dict' : undeclared identifier
netifaces.c(722) : error C2065: 'dict' : undeclared identifier
netifaces.c(722) : warning C4047: '=' : 'int' differs in levels of indirection f
rom 'PyObject *'
netifaces.c(724) : error C2065: 'dict' : undeclared identifier
netifaces.c(734) : error C2065: 'dict' : undeclared identifier
netifaces.c(734) : warning C4047: 'function' : 'PyObject *' differs in levels of
indirection from 'int'
netifaces.c(734) : warning C4024: 'PyDict_SetItemString' : different types for f
ormal and actual parameter 1
netifaces.c(736) : error C2065: 'dict' : undeclared identifier
netifaces.c(736) : warning C4047: 'function' : 'PyObject *' differs in levels of
indirection from 'int'
netifaces.c(736) : warning C4024: 'PyDict_SetItemString' : different types for f
ormal and actual parameter 1
netifaces.c(738) : error C2065: 'dict' : undeclared identifier
netifaces.c(738) : warning C4047: 'function' : 'PyObject *' differs in levels of
indirection from 'int'
netifaces.c(738) : warning C4024: 'PyDict_SetItemString' : different types for f
ormal and actual parameter 1
netifaces.c(744) : error C2065: 'dict' : undeclared identifier
netifaces.c(744) : warning C4047: 'function' : 'PyObject *' differs in levels of
indirection from 'int'
netifaces.c(744) : warning C4024: 'add_to_family' : different types for formal a
nd actual parameter 3
error: command '"c:\Program Files\Microsoft Visual Studio 10.0\VC\BIN\cl.exe"' f
ailed with exit status 2
sorry for the bad formatting
What am I missing?
Rename netifaces.c to netifaces.cpp (and update the setup.py accordingly).
The reason is that with .c extensions, MSVC interprets these files as adhering to C89, which netifaces.c does not follow; more info here:
error C2275 : illegal use of this type as an expression
Related
Trying to build apr 1.7 on Windows with Visual Studio, tried 2017 and 2013.
When building the project (Debug|x86) or compiling e.g. dso.c if get the following error message:
1>dso.c
1>c:\dev\log4cxx\apr\include\arch\win32\apr_arch_misc.h(503): error C2143: syntax error: missing ')' before '*'
1>c:\dev\log4cxx\apr\include\arch\win32\apr_arch_misc.h(503): error C2143: syntax error: missing '{' before '*'
1>c:\dev\log4cxx\apr\include\arch\win32\apr_arch_misc.h(503): error C2059: syntax error: ')'
1>c:\dev\log4cxx\apr\include\arch\win32\apr_arch_misc.h(503): error C2061: syntax error: identifier 'apr_winapi_pfn_if_indextoname'
1>c:\dev\log4cxx\apr\include\arch\win32\apr_arch_misc.h(503): error C2059: syntax error: ';'
1>c:\dev\log4cxx\apr\include\arch\win32\apr_arch_misc.h(503): error C2513: ' ': no variable declared before '='
1>c:\dev\log4cxx\apr\include\arch\win32\apr_arch_misc.h(503): error C2065: 'apr_winapi_pfn_if_indextoname': undeclared identifier
1>c:\dev\log4cxx\apr\include\arch\win32\apr_arch_misc.h(503): warning C4047: '=': 'int' differs in levels of indirection from 'int *(__cdecl *)(NET_IFINDEX,PCHAR)'
1>c:\dev\log4cxx\apr\include\arch\win32\apr_arch_misc.h(503): error C2146: syntax error: missing ';' before identifier 'apr_load_dll_func'
1>c:\dev\log4cxx\apr\include\arch\win32\apr_arch_misc.h(503): error C2100: illegal indirection
1>c:\dev\log4cxx\apr\include\arch\win32\apr_arch_misc.h(503): error C2064: term does not evaluate to a function taking 1207 arguments
1>c:\dev\log4cxx\apr\include\arch\win32\apr_arch_misc.h(503): warning C4033: 'apr_winapi_if_indextoname' must return a value
I have succesfully build version 1.65 (after apply the hint from http://letcoderock.blogspot.com/2017/09/build-log4cxx-trunk-on-windows-by.html or Apache Cross Compilation Error ./gen_test_char: cannot execute binary file)
Comparing apr_arch_misc.h of the two version, i have noticed DLL_IPHLPAPI was new to the enum apr_dlltoken_e and Intelisense was complaining about
APR_DECLARE_LATE_DLL_FUNC(DLL_IPHLPAPI, PCHAR, NETIOAPI_API_, if_indextoname, 0, (
NET_IFINDEX InterfaceIndex,
PCHAR InterfaceName),
(InterfaceIndex, InterfaceName));
with "expecting a ')'".
If have changed NETIOAPI_API_ to WINAPI. Do not know if this is correct but the file could now be compiled (after running the above trick with gen_test_char.exe).
But after that I ran into the next Problem:
1>sockaddr.c
1>network_io\unix\sockaddr.c(144): error C2065: 'IF_NAMESIZE': undeclared identifier
1>network_io\unix\sockaddr.c(144): error C2057: expected constant expression
1>network_io\unix\sockaddr.c(144): error C2466: cannot allocate an array of constant size 0
1>network_io\unix\sockaddr.c(144): error C2133: 'scbuf': unknown size
1>network_io\unix\sockaddr.c(1274): error C2065: 'IF_NAMESIZE': undeclared identifier
I have succesfully build apr with gcc in linux/cygwin. I have looked into the the preprocessor substitutions for IF_NAMESIZE and here it is replaced by 44. But I can not find the definiton or where this is set.
Does anyone have an idea how to fix this? And is the above change to WINAPI correct?
Just use cmake to build the Visual Studio Solution:
With
cmake -G "Visual Studio 15 2017" -A x64
the .sln ist properly set up and building the solution works with no errors. Even gen_test_char.exe is build.
Maybe the apr project should make the cmake building instructions a little bit more prominent on their site.
As written in README file:
Note you must manually modify the include\apr.hw file before you
build to change default options
So i just removed line #define _WIN32_WINNT 0x0501 from apr-1.7.0\include\apr.hw
and run nmake -f Makefile.win. Worked fine for me. VS2017 tools, Windows 10.
In case someone else also runs into this problem: I was using cmake + nmake to build APR, but it still didn't work for me.
The reason was that I had old compilation flags to support Windows XP:
cmake -DMIN_WINDOWS_VER=0x0501 ...
Investigating Iphlpapi.h, it seems that netioapi.h and other networking headers used by the current version of APR are supported only starting from Vista onward:
#if (NTDDI_VERSION >= NTDDI_VISTA)
#include <netioapi.h>
#endif // (NTDDI_VERSION >= NTDDI_VISTA)
So in order for the compilation to work, just remove that cmake option or specify a value higher than 0x0600 (the equivalent for Vista).
I have reduced the problem to these lines:
typedef __int64 int64;
inline int64 qatoll(const char *nptr) { return _atoi64(nptr); }
When compiling in C mode with VC++2008 or 2010 I get errors:
t.c(2) : error C2054: expected '(' to follow 'inline'
t.c(2) : error C2085: 'qatoll' : not in formal parameter list
t.c(2) : error C2143: syntax error : missing ';' before '{'
In C++ mode it does accept the function definition and only complains about _atoi64.
What is the problem and how can I fix it?
Visual C++ 15 compiles it without errors, so is this related to C99 support?
It is not the __int64 which is the problem, but the inline syntax which should be _inline.
I just tried similar code on an older machine running MSVC 2008 to verify this.
Visual C++ Opening a second form
I tried this , but I have a problem
Form1.h
panel^ form2 = gcnew panel;
form2->ShowDialog();
panel.h
#include "Form1.h"
Form1.cpp and panel.cpp
#include "Form1.h"
#include "panel.h"
Error
error C2061: syntax error : identifier 'panel'
error C2065: 'form2' : undeclared identifier
error C2065: 'form2' : undeclared identifier
error C2065: 'panel' : undeclared identifier
error C2227: left of '->ShowDialog' must point to class/struct/union/generic type
it seems you haven't included the headers for Panel.
Include the header where the panel type is declared and compile code.
All errors are due to missing panel declaration
l made a C program and l want to compile it using shell forge but I had several errors, how can I solve them?
Errors
##[ERROR]## compiler reported error 1 while compiling /tmp/sfvLvXlY/sonu.c
##[ERROR]## In file included from :1:
././sflib/linux_amd64/sflib.h:93: warning: "struct rusage" declared inside parameter list
././sflib/linux_amd64/sflib.h:93: warning: its scope is only this definition or declaration, which is probably not what you want
././sflib/linux_amd64/sflib.h:97: warning: "struct sembuf" declared inside parameter list
In file included from /usr/include/stdio.h:34,
from /tmp/sfvLvXlY/sonu.c:3:
/usr/lib/gcc/x86_64-redhat-linux/3.4.6/include/stddef.h:213: error: conflicting types for 'size_t'
././sflib/linux_amd64/../common/sftypes.h:25: error: previous declaration of 'size_t' was here
I'm trying to compile a little project that includes windows.h using the clang compiler. Unfortunately, clang produces some errors I'm not able to resolve. What's causing these errors? Does clang not support all required features, am I missing something?
In file included from C:\Program Files\Microsoft SDKs\Windows\v6.0A\Include/wind
ows.h:155:
In file included from C:\Program Files\Microsoft SDKs\Windows\v6.0A\Include/wind
ef.h:177:
C:\Program Files\Microsoft SDKs\Windows\v6.0A\Include/winnt.h(12857) : warning:
expression result unused [-Wunused-value]
UNREFERENCED_PARAMETER(CallbackEnviron);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:\Program Files\Microsoft SDKs\Windows\v6.0A\Include/winnt.h:12857:28: note: in
stantiated from:
UNREFERENCED_PARAMETER(CallbackEnviron);
^~~~~~~~~~~~~~~
In file included from C:\Program Files\Microsoft SDKs\Windows\v6.0A\Include/wind
ows.h:156:
C:\Program Files\Microsoft SDKs\Windows\v6.0A\Include/winbase.h(2326) : error:
invalid operands to binary expression ('LONGLONG' (aka 'double') and
'LONGLONG')
Old & Value,
~~~ ^ ~~~~~
C:\Program Files\Microsoft SDKs\Windows\v6.0A\Include/winbase.h(2327) : error:
expected ')'
Old) != Old);
^
C:\Program Files\Microsoft SDKs\Windows\v6.0A\Include/winbase.h(2325) : note:
to match this '('
} while (InterlockedCompareExchange64(Destination,
^
C:\Program Files\Microsoft SDKs\Windows\v6.0A\Include/winbase.h(2344) : error:
invalid operands to binary expression ('LONGLONG' (aka 'double') and
'LONGLONG')
Old | Value,
~~~ ^ ~~~~~
C:\Program Files\Microsoft SDKs\Windows\v6.0A\Include/winbase.h(2345) : error:
expected ')'
Old) != Old);
^
C:\Program Files\Microsoft SDKs\Windows\v6.0A\Include/winbase.h(2343) : note:
to match this '('
} while (InterlockedCompareExchange64(Destination,
^
C:\Program Files\Microsoft SDKs\Windows\v6.0A\Include/winbase.h(2362) : error:
invalid operands to binary expression ('LONGLONG' (aka 'double') and
'LONGLONG')
Old ^ Value,
~~~ ^ ~~~~~
C:\Program Files\Microsoft SDKs\Windows\v6.0A\Include/winbase.h(2363) : error:
expected ')'
Old) != Old);
^
C:\Program Files\Microsoft SDKs\Windows\v6.0A\Include/winbase.h(2361) : note:
to match this '('
} while (InterlockedCompareExchange64(Destination,
^
...and a lot more...
You probably need to define a clang-compatible version of the UNREFERENCED_PARAMETER macro. Something like this should help you on the way: https://web.archive.org/web/20130425151054/http://sourcefrog.net/weblog/software/languages/C/unused.html
Also, it seems the type LONGLONG is defined as double for clang, and you can't do binary arithmetic (and, or, not etc) on floats. You need to make sure this is typedefed as a proper integer type.
Depending a bit on how windows.h, winbase.h and winnt.h is structured you may be able to make your own wrapper that gets the right defines in place to make this pass. Otherwise, try to find a gcc-compatible version of windows.h, and use that. Clang should be compatible with it.
Good luck!