delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/02/23/15:15:59

Message-ID: <A34D5D3BF0DFD2119E3D0008C70840FA67DE83@TWZNT11>
From: Nigel Atkinson <Nigel DOT Atkinson AT MeridianEnergy DOT co DOT nz>
To: "'djgpp AT delorie DOT com'" <djgpp AT delorie DOT com>
Subject: RE: d_button_proc - errors in C++, but not C?
Date: Thu, 24 Feb 2000 08:18:38 +1300
MIME-Version: 1.0
X-Mailer: Internet Mail Service (5.5.2650.21)
Reply-To: djgpp AT delorie DOT com

Yeah I've hit this before.
You need to cast the buttons caption ie that string in the dp field, to
(void *) when compiling under C++.  In fact C++ is good for compiling C
progs as it finds mistakes with its stronger type checking.


Nigel Atkinson

-----Original Message-----
From: Riddler02 AT aol DOT com [mailto:Riddler02 AT aol DOT com]
Sent: Wednesday, 23 February 2000 15:25
To: djgpp AT delorie DOT com
Subject: d_button_proc - errors in C++, but not C?


hello once again,

Now that I have begin exploring the wonderful world of Allegro GUI
functions, 
I have come across a slight problem.  The Allegro GUI example program,
EX13.C 
(which is located in C:\DJGPP\ALLEGRO\EXAMPLES for me) compiles n' links and

runs perfectly.  However, if I change its name to EX13.CPP (or anything.cpp 
for that matter), I get the following error at every occurrence of the 
d_button_proc function when I try to compile:
    
    Error: initialization to "void *" from "const char *" discards
qualifiers.

For example, a program with the .CPP extention containing the following 
dialog would compile fine

    DIALOG main_dialog[] = 
        { d_clear_proc, 0, 0, 0, 0, 255, 0, 0, 0, 0, 0, NULL, NULL, NULL  },
          NULL, (blah blah 
blah...........................................................) }
        };

but a dialog with d_button_proc won't

    DIALOG main_dialog[] = 
        { d_clear_proc, 0, 0, 0, 0, 255, 0, 0, 0, 0, 0, NULL, NULL, NULL  },
          d_button_proc, numbers 
numbers.........................................  },          
          NULL, blah blah 
blah...........................................................  }
        };

It would seem that I need to typecast something here, as is the case with 
many C/C++ compatability issues, but I don't know what - pleez help!

-Kevin

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019