The line in question is:
extern BOOL logged_in;
Here are my includes:
#define _WIN32_WINNT 0x0403 // Very important for critical sections.
#define WIN32_LEAN_AND_MEAN // Good to use.
#pragma optimize("gsy", on) // Global optimization, Short sequences, Frame pointers.
#pragma comment(linker, "/RELEASE") // Release code
#pragma comment(linker, "/opt:nowin98")
#pragma comment(linker, "/ALIGN:4096") // This will save you some size on the executable.
#pragma comment(linker, "/IGNORE:4108 ") // This is only here for when you use /ALIGN:4096.
#pragma comment(linker, "/ALIGN:4096") // This will save you some size on the executable.
//default headers
#include <windows.h>
#include <stdio.h>
#include <string.h>
#include <winsock2.h>
#include <time.h>
#include <stdlib.h>
#include <Winsvc.h>
#include <winuser.h>
#include <tlhelp32.h>
#include <tchar.h>
#include <shlobj.h>
#include <shlwapi.h>
#include <shellapi.h>
#include <commctrl.h>
#pragma comment(lib, "ws2_32.lib")
#pragma comment(lib, "urlmon.lib")
#pragma comment(lib, "shlwapi.lib")
#pragma comment(lib, "shell32.lib")
Any ideas?
I don't see the line in the above code, but "missing ‘;’ before identifier" means that you are missing a semicolon before that line.
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>
Disclaimer: C++ Redefinition Header Files (winsock2.h) doesnt solved my problem
In this project, im trying to take a screenshot and then compressing it with libjpeg-turbo. The problem is that i get errors like
"sockaddr": "struct" Type redefinition
and
"nothl": Redefinition
ScreenWorker.h:
#pragma once
#ifndef SCREENWORKER_H
#define SCREENWORKER_H
#include <string>
#include <vector>
#include <thread>
#include <turbojpeg.h>
#include <Windows.h>
#include "..\API\NetClient.h"
class ScreenWorker {
private:
NetClient* client;
public:
int delay = 30;
ScreenWorker(NetClient* client);
HBITMAP GetScreenBmp(HDC hdc);
void Update();
};
#endif
ScreenWorker.cpp:
#include "ScreenWorker.h"
ScreenWorker::ScreenWorker(NetClient* client) {
this->client = client;
Update();
}
HBITMAP ScreenWorker::GetScreenBmp(HDC hdc) {...}
void ScreenWorker::Update() {...}
The main.cpp (DLL-Entry):
#pragma once
#include "..\..\Base\API\API\GladOSClient.h"
#include "ScreenWorker.h"
using namespace std;
BOOL WINAPI DllMain(HINSTANCE Instance, DWORD Reason, LPVOID Reserved) {
return true;
}
NetClient.h (only Header part):
#pragma once
#ifndef NETCLIENT_H
#define NETCLIENT_H
#define _WINSOCKAPI_
#include <Windows.h>
#include <winsock2.h>
#include <ws2tcpip.h>
#include <vector>
#include <list>
#include <mutex>
#include <map>
#include <string>
#pragma comment (lib, "Ws2_32.lib")
#pragma comment (lib, "Mswsock.lib")
#pragma comment (lib, "AdvApi32.lib")
#include "Utils.h"
#include "PacketHandler.h"
#include "Packet.h"
...
#endif
As you can see, i'm using header-guards everywhere, but nevertheless i get those errors. Seems like there is a problem with the including of "Windows.h"?
Thanks in advance!
Edit
I guess the problem has something to do with the way libjpegturbo handles the including of "Windows.h". Currently i have no real way of solving this issue. Maybe im trying exporting the function i need in a seperated DLL... hopefully this will solve it.
Classic issue.
Just remove this line from NetClient.h
#include <Windows.h>
The inclusion of <Winsock2.h> will pull in <windows.h> for you and correct all those redefine issues.
I get the error
mongoclient.lib(assert_util.obj) : error LNK2005: void __cdecl mongo::uasserted(...) already defined in someOwnFile.obj
at linking, along with mongo::msgasserted and mongo::msgasserted.
In someOwnFile.cpp, I have
#include <string>
#ifdef WIN32
// Needed for mongo BSON.
#pragma warning(push)
#pragma warning(disable: 4800)
#pragma warning(disable: 4244)
#pragma warning(disable: 4267)
#define _CRT_SECURE_NO_WARNINGS 1
#endif
#include <mongo/bson/bson.h>
#ifdef WIN32
#pragma warning(pop)
#endif
// ...
Why do I get the error? How can I fix it?
It seems that it has problems when including just this file.
Now I'm doing this:
#ifdef WIN32
// Mongo uses boost.filesystem. Include it here to force to link it in (via its pragma lib).
#include <boost/filesystem.hpp>
// Needed for mongo BSON.
#pragma warning(push)
#pragma warning(disable: 4800)
#pragma warning(disable: 4244)
#pragma warning(disable: 4267)
#define _CRT_SECURE_NO_WARNINGS 1
#endif
#include <mongo/client/dbclient.h>
#include <mongo/client/dbclient_rs.h>
#include <mongo/client/gridfs.h>
#ifdef WIN32
#pragma warning(pop)
#endif
And this works.
I'm compiling at a high warning level and while I have no warnings in my code, I get tens of thousands from included headers.So to disable them I do this:
#pragma warning(push)
#pragma warning(disable : 4365)
#include <D3Dcommon.h>
#include <d3d11.h>
#include <d3d11_1.h>
#pragma comment(lib, "d3d11.lib")
#include <d3dCompiler.h>
#include <D3D11Shader.h>
#pragma comment(lib, "D3DCompiler.lib")
#include <dxgiformat.h>
#include <dxgi.h>
#pragma warning(pop)
The problem is, I also have 5-6 disabled warnings in a header that is included everywhere in my code(for the entire project to see) and using the above pragmas for some reason enables them all back, giving me 150 thousand unwanted warnings all over the entire project.
The header with the 5-6 disabled warnings just lists them like this:(#### being different numbers)
#pragma warning(disable : ####)
#pragma warning(disable : ####)
#pragma warning(disable : ####)
#pragma warning(disable : ####)
......
I'm not using push or pop there, since I want them to be disabled everywhere.
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>