C2065: 'D3DFORMAT': undeclared identifier - c++

When I tried to compile simple GTA San Andreas ASI (dll) project using SDK, I saw error
C2065 'D3DFORMAT': undeclared identifier.
Line: RwBool _rwD3D9CheckValidCameraTextureFormat(D3DFORMAT format); // 0x4CBE20
Interesting thing is that, a few months ago, before reset to factory settings (Windows 10) all was ok.
I tried on Visual Studio 2015/2017/2019.
My code is so simple, because all is in SDK. (https://github.com/DK22Pac/plugin-sdk)
#include "plugin.h"
#include "common.h"
#include "CTimer.h"
#include "CStreaming.h"
using namespace plugin;
class PlayerWeapon {
public:
PlayerWeapon() {
static int keyPressTime = 0;
Events::gameProcessEvent += [] {
CPed *playa = FindPlayerPed();
if (playa && KeyPressed(VK_TAB) && CTimer::m_snTimeInMilliseconds - keyPressTime > 500) {
keyPressTime = CTimer::m_snTimeInMilliseconds;
CStreaming::RequestModel(MODEL_M4, 2);
CStreaming::LoadAllRequestedModels(false);
playa->GiveWeapon(WEAPON_M4, 10, true);
playa->SetCurrentWeapon(WEAPON_M4);
CStreaming::SetModelIsDeletable(MODEL_M4);
}
};
}
} playerWeapon;

Related

Cannot open include file: 'cxxabi.h': No such file or directory

I am making a game that can be played on mac and windows with cocos2d-x.
I first wrote the code in mac's Xcode, and it worked on mac.
When I took the project to windows and tried to build it in Visual Studio 2017, an error occurred.
Error C1083 Cannot open include file: 'cxxabi.h': No such file or directory Narazumono c:\users\masanori\desktop\narazumono3.17\classes_win\nrzcoding.cpp 10
I use cxxabi.h to get the class name of the object.
#include "NRZCoding.h"
#include <cxxabi.h>
#include <cstdio>
#include <algorithm>
#include "NRZUtils.h"
using namespace std;
USING_NS_CC;
namespace NRZCoding {
...
const string& EncodableObject::getClassName()
{
if (_className.size() > 0) {
return _className;
}
const type_info& id = typeid(*this);
int stat;
char *name = abi::__cxa_demangle(id.name(),0,0,&stat);
CCASSERT(name != NULL && stat == 0, "failed to demangle");
_className = string(name);
free(name);
return _className;
}
...
What do I need to do?
I am using cocos2d-x 3.17.1 and Visual Studio 2017.
Thank you.

engine.h is not recognized in Visual Studio c++

I've make all the settings in Visual for this code:
#include "stdafx.h"
#include <stdio.h>
#include <cstdlib>
#include <iostream>
#include <stdlib.h>
#define BUFSIZE 1000
int main ()
{
Engine *ep;
if (!(ep = engOpen("\0"))) {
fprintf(stderr, "\nCan't start MATLAB engine\n");
return EXIT_FAILURE;
}
system("pause");
return 0;
}
and i still get this error:
Error 2 error C2065: 'Engine' : undeclared identifier
Error 3 error C2065: 'ep' : undeclared identifier
Error 4 error C2065: 'ep' : undeclared identifier
Error 5 error C3861: 'engOpen': identifier not found

error C2061: syntax error : identifier 'IXMLDOMDocument'

I'm building a GTK+ VS2010 project configuration on (VS2013) and I'm trying to add a browse folder functionality (I want to use Native Windows way). I'm using the following code:
#include <windows.h>
#include <ShlObj.h>
DWORD WINAPI BrowseFolder(void *ptr)
{
char path[MAX_PATH];
cchar * path_param = (cchar*)ptr;
BROWSEINFO bi = { 0 };
bi.lpszTitle = ("Select Folder");
bi.ulFlags = BIF_RETURNONLYFSDIRS | BIF_NEWDIALOGSTYLE;
bi.lpfn = BrowseCallbackProc;//callback function defined..
bi.lParam = (LPARAM)path_param;
LPITEMIDLIST pidl = SHBrowseForFolder(&bi);
if (pidl != 0)
{
//get the name of the folder and put it in path
SHGetPathFromIDList(pidl, path);
//free memory used
IMalloc * imalloc = 0;
if (SUCCEEDED(SHGetMalloc(&imalloc)))
{
imalloc->Free(pidl);
imalloc->Release();
}
strcpy(g_sDefaultDir, path);
return 0;
}
}
but when compiling I'm getting this error message
1>C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\Include\shobjidl.h(17624): error C2061: syntax error : identifier 'IXMLDOMDocument'
This is my configuration:
I'm running VS2010 solution on VS2013
Use Standard Windows Libraries
Not Using ATL
and Use Multi-Byte character set
Any ideas?
I found 2 ways to answer solve my problem.
I had msxml and ISoftDistExt previously defined to solve ambiguity problem, so I had to #undef them like the following:
#undef __msxml_h__
#undef __ISoftDistExt_INTERFACE_DEFINED__
#include <MsXml.h>
#include <ShlObj.h>
Also, you can use the #import statement like the follownig
#undef __msxml_h__
#undef __ISoftDistExt_INTERFACE_DEFINED__
#import <msxml6.dll>
using namespace MSXML2;
#include <ShlObj.h>
Hope this will help someone later.

Allegro4/C++ giving error

I'm using the following code (Allegro 4, C++), and getting the following error:
#include <allegro.h>
//defines
#define MODE GFX_SAFE
#define WIDTH 640
#define HEIGHT 480
int main (void)
{
int ret;
int counter;
//initialize allegro
allegro_init();
install_keyboard();
install_timer();
srand(time(NULL));
//set up screen
//set video mode
ret = set_gfx_mode(MODE, WIDTH, HEIGHT, 0, 0);
if (ret != 0)
allegro_message(allegro_error);
allegro_exit();
return 0;
}
Error:
1>MSVCRTD.lib(crtexe.obj) : error LNK2019: unresolved external symbol _main referenced in function ___tmainCRTStartup
All the previous answers regarding that error tell me to switch to "Console" from "Windows"; but I already have "Console" in Properties->Linker->System->Subsystem.
If you don't have an answer, I'd be happy with something I could do to help narrow down the problem: I've used Allegro with C, but I want to use C++ to take advantage of OOP, and so I still have a lot of work to do.
Update:
#include <iostream>
#include <allegro.h>
using namespace std;
int main ()
{
cout << "Hello World";
return 0;
}
doesn't work, but
#include <iostream>
using namespace std;
int main ()
{
cout << "Hello World";
return 0;
}
does.
Now what? Answer: Start with Empty project.
Update2: restarted with an empty project, same code. First block (alleg.lib in linker, but allegro.h not included) works, second code (allegro.h included) doesn't. However, the bug is different:
1>LINK : fatal error LNK1561: entry point must be defined
What now?
Edit^2:Ignore all the following: I forgot to go back to including Allegro. It works now. Thanks everyone for the answers.
Edit: Adding:
END_OF_MAIN()
or
int END_OF_MAIN()
give the error "fatal error C1004: unexpected end-of-file found"
You are getting the error because you are attempting to integrate allegro into a project that is non-empty.
You must create the project as an EMPTY PROJECT type:
New... > Project... > Visual C++ > Empty Project
--EDIT FOR SECOND ERROR--
You must append END_OF_MAIN() after the closing brace of int main():
int main() {
//...
}
END_OF_MAIN()

DataContractSerialize error

Here a little test code illustrating the problem:
Compiling configurations:
Common Language Runtime Support: /clr
C++ Language
Error message:
Error 4 error C2065: 'DataContractSerializer' : undeclared identifier C:...\SerializationTest.cpp 21 1 SerializationTest
The code:
// SerializationTest.cpp : main project file.
#include "stdafx.h"
using namespace System::Collections::Generic;
using namespace System;
using namespace System::IO;
using namespace System::Xml;
using namespace System::Runtime::Serialization;
int main(array<System::String ^> ^args)
{
Console::WriteLine(L"Hello World");
Dictionary<System::String^, System::Double>^ teste = gcnew Dictionary<System::String^, System::Double>();
teste->Add("Teste1",2);
teste->Add("Teste2",4);
DataContractSerializer^ serializer = gcnew DataContractSerializer(teste->GetType());
StringWriter^ writer = gcnew StringWriter();
XmlTextWriter^ stm = gcnew XmlTextWriter(writer);
serializer->WriteObject(stm, teste);
Console::WriteLine(writer->ToString());
return 0;
}
It sounds simply like you're missing a reference to System.Runtime.Serialization.dll (which is required in addition to the using directive):
#using <System.Runtime.Serialization.dll>