I've made this declaration in my include file:
__inline struct _PEB * NtCurrentPeb() { return NtCurrentTeb()->ProcessEnvironmentBlock; }
Leading the file also includes these values:
#include <stdio.h>
#include <windows.h>
#include <WinNT.h>
#pragma comment(lib, "ntdll.lib")
But the compiler (Rad Studio XE 10) gives me this error:
Use of undeclared identifier 'NtCurrentTeb'
Where am I wrong? What is missing?
Related
When I include gdiplus.h in a program that compiles well the first(there are many) error I get is:
c:\program files (x86)\microsoft sdks\windows\v7.0a\include\GdiplusImaging.h(77): error C2504: 'IUnknown' : base class undefined
Part of GdiplusImaging.h:
IImageBytes : public IUnknown <<< error!
{
public:
...
Why it is so? Where is this IUnknown class? And why it's not in GdiplusImaging.h?
My system is Windows7 x64. VisualStudio 2010.
Including part:
#include <windows.h>
#include <gdiplus.h>
using namespace Gdiplus;
#pragma comment (lib, "gdiplus.lib")
These are the standard includes for using GDI+:
#include <windows.h>
#include <objidl.h>
#include <gdiplus.h>
using namespace Gdiplus;
#pragma comment (lib,"Gdiplus.lib")
You should try to add windows.h and Unknwn.h header before gdiplus.h
#include <Unknwn.h>
#include <windows.h>
#include <gdiplus.h>
I am trying to run a project using Visual studio 2003. But I am getting lot of compilation errors similar to the following.
The errors are pointing to WinSock2.h file. I am copying couple of code snippets from WinSock2.h file and the corresponding errors
typedef struct fd_set {
u_int fd_count; /* how many are SET? */
SOCKET fd_array[FD_SETSIZE]; /* an array of SOCKETs */
} fd_set;
C:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\PlatformSDK\Include\WinSock2.h(114): error C2065: 'fd_set' :
undeclared identifier
struct sockaddr {
u_short sa_family; /* address family */
char sa_data[14]; /* up to 14 bytes of direct address */
};
C:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\PlatformSDK\Include\WinSock2.h(109): error C2143: syntax
error : missing ';' before '{'
The ws2_32.lib file is added to "Configuration properties - Linker - Input - Additional Dependencies". The build configuration platform is win32.
Thanks in advance for your help.
a typical basic Winsock Application with the good order of header files can be found here:
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif
#include <windows.h>
#include <winsock2.h>
#include <ws2tcpip.h>
#include <iphlpapi.h>
#include <stdio.h>
#pragma comment(lib, "Ws2_32.lib")
int main() {
return 0;
}
The order of including header files is important
I need help compiling "http://cekirdek.pardus.org.tr/~ismail/ffmpeg-docs/api-example_8c-source.html" using visual studio express 2013.
I followed the solution indicated in "Use FFmpeg in Visual Studio", however I still get the message "error C1189: #missing -D__STDC_CONSTANT_MACROS / #define __STDC_CONSTANT_MACROS
Thanks,
Please try it, it should work.
#include <math.h>
extern "C" {
#ifndef __STDC_CONSTANT_MACROS
#define __STDC_CONSTANT_MACROS
#endif
#include <libavutil/opt.h>
#include <libavcodec/avcodec.h>
#include <libavutil/channel_layout.h>
#include <libavutil/common.h>
#include <libavutil/imgutils.h>
#include <libavutil/mathematics.h>
#include <libavutil/samplefmt.h>
}
When I include gdiplus.h in a program that compiles well the first(there are many) error I get is:
c:\program files (x86)\microsoft sdks\windows\v7.0a\include\GdiplusImaging.h(77): error C2504: 'IUnknown' : base class undefined
Part of GdiplusImaging.h:
IImageBytes : public IUnknown <<< error!
{
public:
...
Why it is so? Where is this IUnknown class? And why it's not in GdiplusImaging.h?
My system is Windows7 x64. VisualStudio 2010.
Including part:
#include <windows.h>
#include <gdiplus.h>
using namespace Gdiplus;
#pragma comment (lib, "gdiplus.lib")
These are the standard includes for using GDI+:
#include <windows.h>
#include <objidl.h>
#include <gdiplus.h>
using namespace Gdiplus;
#pragma comment (lib,"Gdiplus.lib")
You should try to add windows.h and Unknwn.h header before gdiplus.h
#include <Unknwn.h>
#include <windows.h>
#include <gdiplus.h>
The whole error is:
Error 1 error C2065: 'socklen_t' : undeclared identifier c:\users\richard\documents\visual studio 2010\projects\server\server\server.cpp 41 1 Server
This is the problematic line:
int iRcvdBytes=recvfrom(iSockFd, buff, 1024000, 0, (struct sockaddr*)&cliAddr, (socklen_t*)&cliAddrLen);
I have these headers included:
#include <winsock2.h>
#include <windows.h>
#include <direct.h>
#include <stdlib.h>
#include <stdio.h>
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <cv.h>
#include <cxcore.h>
#include <highgui.h>
I have also added WS2_32.lib to the linker in Visual Studio 2010.
What else could cause this problem? I'm just trying to rewrite my simple UDP program to work under Windows.
The socklen_t type is defined inside of WS2tcpip.h in windows. This is not transitively included from winsock2.h (AFAICT). You'll need to include WS2tcpip.h manually in order to use the socklen_t type.
Visual Studio can't find the type socklen_t. MSDN says that this function takes an int* as the last parameter, so cast to that.