Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » Compile Errors

Credits go to Dennis, Kitty Cat, ReyBrujo, Ultio, and Wetimer for helping out!
This thread is locked; no one can reply to it. rss feed Print
 1   2 
Compile Errors
Rick
Member #3,572
June 2003
avatar

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?

========================================================
Actually I think I'm a tad ugly, but some women disagree, mostly Asians for some reason.

Ultio
Member #1,336
April 2001

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.

---
"It's nice knowing that someday, the software I write will just be pirated by millions of people." :-/
http://loomsoft.net | Zep's Dreamland | Allegro Newbie Tutorials

ReyBrujo
Moderator
January 2001
avatar

Include winalleg.h after allegro.h.

--
RB
光子「あたしただ…奪う側に回ろうと思っただけよ」
Mitsuko's last words, Battle Royale

Rick
Member #3,572
June 2003
avatar

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.

========================================================
Actually I think I'm a tad ugly, but some women disagree, mostly Asians for some reason.

Ultio
Member #1,336
April 2001

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?

---
"It's nice knowing that someday, the software I write will just be pirated by millions of people." :-/
http://loomsoft.net | Zep's Dreamland | Allegro Newbie Tutorials

Rick
Member #3,572
June 2003
avatar

Quote:

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

Nope

========================================================
Actually I think I'm a tad ugly, but some women disagree, mostly Asians for some reason.

Ultio
Member #1,336
April 2001

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.

---
"It's nice knowing that someday, the software I write will just be pirated by millions of people." :-/
http://loomsoft.net | Zep's Dreamland | Allegro Newbie Tutorials

ReyBrujo
Moderator
January 2001
avatar

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

--
RB
光子「あたしただ…奪う側に回ろうと思っただけよ」
Mitsuko's last words, Battle Royale

Rick
Member #3,572
June 2003
avatar

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

========================================================
Actually I think I'm a tad ugly, but some women disagree, mostly Asians for some reason.

Ultio
Member #1,336
April 2001

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?

---
"It's nice knowing that someday, the software I write will just be pirated by millions of people." :-/
http://loomsoft.net | Zep's Dreamland | Allegro Newbie Tutorials

Wetimer
Member #1,622
November 2001

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.

<code>if(Windows.State = Crash) Computer.halt();</code>

Kitty Cat
Member #2,815
October 2002
avatar

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

--
"Do not meddle in the affairs of cats, for they are subtle and will pee on your computer." -- Bruce Graham

Rick
Member #3,572
June 2003
avatar

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

========================================================
Actually I think I'm a tad ugly, but some women disagree, mostly Asians for some reason.

Kitty Cat
Member #2,815
October 2002
avatar

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.

--
"Do not meddle in the affairs of cats, for they are subtle and will pee on your computer." -- Bruce Graham

Rick
Member #3,572
June 2003
avatar

Ah it's probably tinyXML doing it.

========================================================
Actually I think I'm a tad ugly, but some women disagree, mostly Asians for some reason.

Dennis
Member #1,090
July 2003
avatar

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
Member #3,572
June 2003
avatar

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?

========================================================
Actually I think I'm a tad ugly, but some women disagree, mostly Asians for some reason.

ReyBrujo
Moderator
January 2001
avatar

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

--
RB
光子「あたしただ…奪う側に回ろうと思っただけよ」
Mitsuko's last words, Battle Royale

Wetimer
Member #1,622
November 2001

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.

<code>if(Windows.State = Crash) Computer.halt();</code>

Kitty Cat
Member #2,815
October 2002
avatar

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

--
"Do not meddle in the affairs of cats, for they are subtle and will pee on your computer." -- Bruce Graham

Rick
Member #3,572
June 2003
avatar

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.

========================================================
Actually I think I'm a tad ugly, but some women disagree, mostly Asians for some reason.

Neil Walker
Member #210
April 2000
avatar

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.

Neil.
MAME Cabinet Blog / AXL LIBRARY (a games framework) / AXL Documentation and Tutorial

wii:0356-1384-6687-2022, kart:3308-4806-6002. XBOX:chucklepie

Rick
Member #3,572
June 2003
avatar

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.

========================================================
Actually I think I'm a tad ugly, but some women disagree, mostly Asians for some reason.

Neil Walker
Member #210
April 2000
avatar

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.

Neil.
MAME Cabinet Blog / AXL LIBRARY (a games framework) / AXL Documentation and Tutorial

wii:0356-1384-6687-2022, kart:3308-4806-6002. XBOX:chucklepie

Rick
Member #3,572
June 2003
avatar

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. :)

========================================================
Actually I think I'm a tad ugly, but some women disagree, mostly Asians for some reason.

 1   2 


Go to: