Been working on this little thing for a few months now, having some issues with some structs. This compiled correctly in vs 2003 but doesnt work properly in c++ 2005. (Most of this is others work and open sourced stuff) Any help is appreciated with why I ths doesnt work.

CODE
#ifdef _DEFINE_VARS
#define MYVAR(type, name) type v##_##name;
#define DEFINEVAR(type, name) type name;
#define MYCARRAY(type, name) CArrayEx<type, type> v_##name;
#define MYTOGGLE(name) BOOL v_##name; INT vK_##name;
#define MYKEY(name) INT vK_##name;
CArrayEx<LevelNameInfo*, LevelNameInfo*> LevelNames;

#else

#define MYVAR(d1, v1) extern d1 v_##v1;
#define DEFINEVAR(type, name) extern type name;
#define MYCARRAY(type, name) extern CArrayEx<type, type> v_##name;
#define MYTOGGLE(name) extern BOOL v_##name; extern INT vK_##name;
#define MYKEY(name) extern INT vK_##name;
extern CArrayEx<LevelNameInfo*, LevelNameInfo*> LevelNames;

#endif

MYVAR(DLLINFO, DllInfo)


CODE
#ifndef _COMMONSTRUCTS_H
#define _COMMONSTRUCTS_H

typedef struct DllInfo_t
{
DWORD dwBaseAddress;
DWORD dwImageSize;
CHAR szModulePath[MAX_PATH];
DWORD dwMagicNumber;
} DLLINFO, *PDLLINFO;

Errors
vars.h(20) : error C2146: syntax error : missing ';' before identifier 'v_DllInfo'
vars.h(20) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int

commonstructs.h(16) : error C2378: 'DLLINFO' : redefinition; symbol cannot be overloaded with a typedef
vars.h(20) : see declaration of 'DLLINFO'

Recommended Answers

All 11 Replies

Can you add a semicolon after MYVAR(DLLINFO, DllInfo), like

MYVAR(DLLINFO, DllInfo);

It may cause an error, if I assume that it is line 20 of vars.h.

yes that is line 20 of vars.h

Adding a semi colon gives an error, and there was no semicolon in the original source that I pulled that code from.

If anyone would like to look at my sources its not a problem, may make it easier for you guys to understand and help me out.

>Can you add a semicolon after MYVAR(DLLINFO, DllInfo), like
Look at macro definition, the macro itself is adding a semi-colon. Adding a semicolon will actually add two semicolons.

@joejoe55
Yeah, you should send the code. If is huge, just attach it, otherwise paste it here.

http://www.yourfilehost.com/media.php?cat=...HackProject.zip

Source is a few mbs so I just uploaded it, if you cant tell what it is its just a little plugin to draw some things on screen for a single player game that I play. Its all pretty basic, just shows my current winamp track and some other basic stuff. This is mostly a starter project for me and contains alot of other people work so dont laugh if its messy!

SEARCH MILLIONS OF VIDEOS:


Error: no file category

You will be redirected to the Top 50 page in 5 seconds

This is what I get while opening your link

anyone else have any ideas for me?

CommonStructs.h needs to be #included before Vars.h is included.
I.e.

#include ...
#include "CommonStructs.h" 
#include "Vars.h"
#include ...

As of now, the order of inclusion is wrong.

In future, when you post a project, please Clean it before zipping, so that all the unnecessary binaries (*.obj etc) get deleted. The Clean command is in the Build menu.

wow i cant believe i made such a stupid mistake, this has had me lost for weeks, thank you so much for the help and sorry about the messy project, ive only been coding for about 4months and its all from books/ some online resources so im still pretty new to the scene, I have a couple errors that I will try and get sorted out regarding unresolved externals but thank you so much for your help!

Creating library C:\Documents and Settings\Chris\Desktop\mymMap\MymMap.lib and object C:\Documents and Settings\Chris\Desktop\mymMap\MymMap.exp
1>MymMap.exp : warning LNK4070: /OUT:mMap.dll directive in .EXP differs from output filename 'C:\Documents and Settings\Chris\Desktop\mymMap\MymMap.dll'; ignoring directive
1>Helpers.obj : error LNK2001: unresolved external symbol "struct DllInfo_t v_DllInfo" (?v_DllInfo@@3UDllInfo_t@@A)
1>C:\Documents and Settings\Chris\Desktop\mymMap\MymMap.dll : fatal error LNK1120: 1 unresolved externals
1>Build log was saved at "file://c:\Documents and Settings\Chris\Desktop\Maphack Project\mMap\Debug\BuildLog.htm"
1>mMap - 2 error(s), 3 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========


Still something wrong with dllinfo struct, If anyone could assist, the project is complete once that struct is working, cant seem to figure out the unresolved symbol..

Could you post the latest version of the project?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.