Compile Errors
Rick

I'm trying to take a project from Dev-C++ to MSVC++ 6.0, and where it compiles fine in Dev I get:

c:\program files\microsoft visual studio\vc98\include\wingdi.h(486) : error C2371: 'BITMAP' : redefinition; different basic types
        c:\program files\microsoft visual studio\vc98\include\allegro\gfx.h(220) : see declaration of 'BITMAP'
c:\program files\microsoft visual studio\vc98\include\wingdi.h(3429) : error C2229: struct 'tagDIBSECTION' has an illegal zero-sized array

errors with MSVC. Anyone know what is going on?

Ultio

What kind of project did you create when you started the MSVC project? It should be a "Win32" application and not "Win32 Console Application", or something else. That's the only thing I can think of that might be pulling wingdi.h into your project for no good reason.

ReyBrujo

Include winalleg.h after allegro.h.

Rick

I created 2 projects cause I thought that was it, but I get the same for both. Once in a project where do you check/change that?

Quote:

Include winalleg.h after allegro.h.

I don't include winalleg at all.

Ultio

I have no idea. I haven't used MSVC 6.0 in a long time. I'd say start over and use RB's advice. I'm assuming you're trying to use some Windows specific stuff in conjunction with Allegro, no?

Rick
Quote:

I'm assuming you're trying to use some Windows specific stuff in conjunction with Allegro, no?

Nope

Ultio

Hmm. When you choose to make a new "Win32" project, are you ensuring the the project is "empty" when it's created? I think there's a checkbox to create empty projects. This is more important in MSVC7, but I might also be required in MSVC6.

ReyBrujo

Hmm.. you created an empty project, or created one that includes a stdafx.h file? If so, begin again and create an empty one.

Rick

Same error. Here is what I do:

1) Create empty Win32 Application, call stacked
2) Copy off my source files from Dev, and past them in the stacked directory created by MSVC (this includes a sub directory for tinyXML)
3) Project->Add To Project->Add Files, include all source files
4) Link in alld.lib
5) compile and getts errors

Ultio

Are you sure you're not including some file that DevCPP created in order to work correctly? I don't know much about DevCPP and what it requires to work right. I'm guessing that it wouldn't make any weirdo files that are going to include Windows specific stuff (when dealing with Allegro programs), but you never know.

Have you tried making a new project that has the barebones for ensuring that Allegro works in your MSVC studio?

Wetimer

It looks as if you are somehow including the windows header. Probably in MSVC some of the standard headers do that. Whatever file is giving you errors, put this at the top.

#include <allegro.h>
#include <winalleg.h>

That magic should fix the errors.

Kitty Cat

You're including something that includes windows.h. You need to include allegro and winalleg.h before whatever it is.

Rick
Quote:

Have you tried making a new project that has the barebones for ensuring that Allegro works in your MSVC studio?

A small allegro app works.

I've never had this problem before.

I'll try your fix Ewert but I still don't understand why it's doing this, when it works normally.

Quote:

You're including something that includes windows.h.

I'm not doing anything out of the normal. Like I said it compiles with Dev

Kitty Cat
Quote:

I'm not doing anything out of the normal. Like I said it compiles with Dev

Doesn't mean much. MSVC is probably trying to pull in a Windows header from a "standard" header, which pulls in windows.h.

Rick

Ah it's probably tinyXML doing it.

Dennis

Did you remember to select "MULTITHREADED DLL" for the runtime-lib on the "code generation" project-settings page?

Kitty Cat said:

Doesn't mean much. MSVC is probably trying to pull in a Windows header from a "standard" header, which pulls in windows.h.

On MSVC6 this is not the case, when you create an empty win32 app.
(Neither MFC nor any standard headers will be used then.)

Rick

OK, it's tinyXML doing it. Ran a since int main() with allegro and it worked, and as soon as I included tinyxml.h I get that error. So what should I do with tinyXML to get around this, while still keeping cross-platform code?

[edit]
Here is it:

#if defined( DEBUG ) && defined( _MSC_VER )
#include <windows.h>
#define TIXML_LOG OutputDebugString
#else
#define TIXML_LOG printf
#endif

[edit]
putting
#include <allegro.h>
#include <winalleg.h>
Works, but I don't want to keep putting this and commenting it out when I use it for allegro or non-allegro programs. How can I make this easier? Some kind of #define maybe?

ReyBrujo

Include <winalleg.h> instead of <windows.h> in tynixml.

Wetimer

Allegro.h probably defines ALLEGRO_H or something. You could use #ifdefs to detect that and include winalleg.h if allergo.h has been included already.

Kitty Cat
#include <allegro.h>
#ifdef ALLEGRO_WINDOWS
#include <winalleg.h> // tinyXML hack
#endif
#include <tinyxml.h>
...

Rick
Quote:

Include <winalleg.h> instead of <windows.h> in tynixml.

That doesn't help if I'm not creating a non allegro program does it? Anyway I just did:

#if defined( DEBUG ) && defined( _MSC_VER )
#include <allegro.h>
#include <winalleg.h>
#include <windows.h>
#define TIXML_LOG OutputDebugString
#else
#define TIXML_LOG printf
#endif

and it work. Thanks all.

Neil Walker

tinyXML works fine with VC6.

Here is my main header file:

#include <string>
#include <map>
#include <vector>
#include <sstream>
#include <stdio.h>
#include <time.h>
#include <math.h>
#include <allegro.h>
#ifdef _WIN32
  #include <winalleg.h> //allow tinyXML to include windows.h
#endif
#include "extern/tinyxml_minimum/tinyxml.h"

Is this what you are doing as you have to have the winalleg.h entry.

Neil.

Rick
Quote:

tinyXML works fine with VC6.

I know, it when you use tinyXML, VC6, and allegro together when you get the problem. It won't compile as is.

Neil Walker

Observe the #include<allegro.h> entry, that is why I'm posting here as I use allegro and tinyxml and vc6 :)

Are you including allegro, then winalleg then tinyxml, in that order?

Neil.

Rick
Quote:

#ifdef _WIN32
#include <winalleg.h> //allow tinyXML to include windows.h
#endif

I understand that, but you said:
<code>
tinyXML works fine with VC6.
<code>
I agree, but I am just saying that tinyxml doesn't compile out of the box sort of speak with allegro and msvc. You need to do the extra "winalleg.h" which I was unaware of. You don't need to do this with DEV-C++. So instead of putting the #ifdef in my code, I put it in tinyxml.h, where it's easier. I'll switch between compilers and that would always be a gotcha I would never remember. :)

Neil Walker

The reason for the error is that the tinyXML header has the following line:
#include <windows.h>

It doesn't actually do anything. I talked to the tinyXML author about this and he just put it in for the sake of putting it in. The reason why it works in Dev-CPP is because DevCPP does not define a Microsoft windows constant :)

You can safely remove this line from tinyXML and all will work.

Neil.

Rick
It doesn't actually do anything. I talked to the tinyXML author about this and he just put it in for the sake of putting it in.

Weird. Got it working. Thanks all. :)

Thread #515597. Printed from Allegro.cc