Build Fail: winsock2.h file not found - objective-c

Added #define _WINSOCKAPI_ but still the build is failing.
/*
* $PostgreSQL: pgsql/src/include/port/win32/sys/socket.h,v 1.7 2006/10/04 00:30:10 momjian Exp $
*/
#ifndef WIN32_SYS_SOCKET_H
#define WIN32_SYS_SOCKET_H
/*
* Unfortunately, <wingdi.h> of VC++ also defines ERROR.
* To avoid the conflict, we include <windows.h> here and undefine ERROR
* immediately.
*
* Note: Don't include <wingdi.h> directly. It causes compile errors.
*/
#define _WINSOCKAPI_ //added this line but no help
#include <winsock2.h>
#include <ws2tcpip.h>
#include <windows.h>
#undef ERROR
#undef small
/* Restore old ERROR value */
#ifdef PGERROR
#define ERROR PGERROR
#endif
/*
* we can't use the windows gai_strerror{AW} functions because
* they are defined inline in the MS header files. So we'll use our
* own
*/
#undef gai_strerror
#endif /* WIN32_SYS_SOCKET_H */

You are trying to compile a Windows-specific header file on a platform that is decidedly not Windows. I can't imagine what you expect this to do; whatever it is, though, it doesn't.

Try using
#ifndef __APPLE__ ... #endif
Then, check out the other compile errors and include apple specific socket files, that also work under BSD socket.

Related

typedef an sc_fixed but got template error

Trying to define a simple sc_fixed type in Visual Studio 2017:
#include <systemc.h>
#include <sysc/datatypes/fx/sc_fixed.h> # just in case
....
typedef sc_fixed<16, 4> fixed_type;
....
This typedef line resulted an error:
E0864: sc_fixed is not a template
Had no idea why this error popped, even included sysc/datatypes/fx/sc_fixed.h. Why does it say "not a template"?
From INSTALL file shipped with SystemC
SystemC 2.3 includes a fixed-point package that is always built.
When compiling your applications with fixed-point types, you still have
to use compiler flag -DSC_INCLUDE_FX. Note that compile times increase
significantly when using this compiler flag.
Using your code as an example
#include <systemc.h>
#include <sysc/datatypes/fx/sc_fixed.h>
#include <iostream>
typedef sc_dt::sc_fixed<16, 4> fixed_type;
int sc_main(int, char**){
fixed_type ft(1.25);
std::cout << "ft = " << ft << '\n';
return 0;
}
Gives me the output
ft = 1.25
As a caveat it is best to check the docs for your particular version of SystemC as I believe this #define may have been removed in 2.3.3 (I am using 2.3.2) I am not certain.
I got the same type of error message in one of my C++ programs - E0864 - unique_ptr is not a template
I managed to get rid of this error in my program by adding this to my header file.
#include <memory>
My program managed to compile okay using this. I am using Visual Studio 2019 if that helps.

I would like to know what #include <tr1/memory> do?

I have this library vesSharedPtr.h which includes the following code:
#ifndef VESSHAREDPTR_H
#define VESSHAREDPTR_H
// C/C++ includes
#include < tr1/memory >
#define vesSharedPtr std::tr1::shared_ptr
#define vesWeakPtr std::tr1::weak_ptr
#endif // VESSHAREDPTR_H
Because when I'm trying to run my project, always appear this error:
#include < tr1/memory > file not found
I encountered this problem when compiling for iOS 7. It works on iOS 6, because the vtk.framework was compiled for iOS 6.

Implicit declaration of function 'ether_ntoa' is invalid in C99

It's part of a series of functions that retrieve IP & Mac addresses from the phone.
strcpy(temp, (char *)ether_ntoa((const struct ether_addr *)LLADDR(sdl)));
EDIT: No equivalent function needed, there were just a few missing headers.
EDIT: Added cast to LLADDR(sdl)
As I read it, the error message isn't claiming that the function is missing, only that you don't include its declaration. (I don't know that it exists, only that the message has a different complaint.)
In case it helps, man ether_ntoa tells me:
#include <sys/types.h>
#include <sys/socket.h>
#include <net/ethernet.h>
I included following header file and source code compiled successfully:
#import <arpa/inet.h>

programatically install headers and dependent headers using scons

I'm using scons as my build system and I'd like to install my project's development headers using scons as well. I'd like to avoid maintaining a list of all the needed headers and their include dependencies and instead use the built-in dependency parsing magic of scons to provide this list for me.
As an example I have 2 headers I want to install, explicitly, Foo1.h and Foo2.h:
/* Foo1.h */
#ifndef FOO1_H_
#define FOO1_H_
#include "Bar.h"
#include <somelibrary.h>
/* header contents */
#endif /* FOO1_H_ */
and
/* Foo2.h */
#ifndef FOO2_H_
#define FOO2_H_
/* header contents */
#endif /* FOO2_H_ */
Since Bar.h is required by Foo1.h, I want it to be installed too, automagically. somelibrary.h shouldn't be part of the installed headers. There has to be some way to accomplish this or there has to be some reason what I'm trying to do isn't advisable.
Thanks for any help!
Well, I figured out the answer. Here's the code snippet that'll do exactly what I was talking about:
def getDependentIncludes(environ, explicit_includes, search_path, depincludes):
for inc in explicit_includes:
if inc not in depincludes:
depincludes.add(inc)
incs = SCons.Defaults.CScan(inc, environ, search_path)
getDependentIncludes(environ, incs, search_path, depincludes)
# create a set of all the headers
development_headers = set()
# call function, with development_headers storing the result
getDependentIncludes(env,
external_facing_headers,
include_dirs, development_headers)
# print the glorious results
names = map(lambda x : '"./' + os.path.relpath(str(x), Dir("#").abspath) + '"', development_headers)
names.sort()
print " ".join(names)

Problem wit MDAC when trying to compile in VS2008 using x64 bit target platform

I am trying to compile an 32 bit application. I am aware of problems with it but that is why its being compiled on 64 bit version.
I am hanging at this problem.
Application uses lots of sql stuff.
In sqltypes.h file: (provided by MDAC)
#ifdef _WIN64
typedef INT64 SQLLEN;
typedef UINT64 SQLULEN;
typedef UINT64 SQLSETPOSIROW;
#else
#define SQLLEN SQLINTEGER
#define SQLULEN SQLUINTEGER
#define SQLSETPOSIROW SQLUSMALLINT
#endif
//For Backward compatibility
#ifdef WIN32
typedef SQLULEN SQLROWCOUNT;
typedef SQLULEN SQLROWSETSIZE;
typedef SQLULEN SQLTRANSID;
typedef SQLLEN SQLROWOFFSET;
#endif
For some reason when its compiled on 32 bit platform it works great
But when I try building it on 64 it goes berserk.
Error 61 error C2146: syntax error : missing ';' before identifier 'SQLLEN' ..\external\microsoft sdk\include\sqltypes.h 50
It does not recognize INT64, UINT64.
Is there something I need to enable so it will work under 64 build process?
Missing some #include or #define?
Any help would be great
Thanks
It turned out the problem was that somehow BaseTsd.h was not included (can't believe this is possible)
but as short fix I just included BaseTsd.h manually... i will comment on this answer if i find better solution
Use
#include <windows.h>
It contains BaseTsd.h and other relevant Windows-specific definitions.