Re: -Crawl- Compiling 4.1a



"Erik Piper" <erik@xxxxxx> writes:
> Darshan Shaligram wrote:
>> "Erik Piper" <erik@xxxxxx> writes:
>> > Error E2268 effects.cc 762: Call to undefined function 'tolower' in
>> > function acquirement(unsigned char,bool)

>> Put in a

>> #include <ctype.h>

>> along with the other #includes.

> Worked. (Also had to be done elsewhere.) Is there a simple "why" for
> this so that I might learn something from the incident?

Sure. The error was caused by the C++ compiler seeing a function call
to the unknown function 'tolower'. The compiler doesn't like unknown
functions, so you need to tell it what the function looks like by
saying (for instance):

int tolower(int);

in effects.cc. That's called a function prototype.

Now, 'tolower' happens to be a standard C function, which means the
compiler writer already did the work of writing all those tiresome
prototypes. In the case of 'tolower', the prototype is in the header
file ctype.h. #including it keeps the compiler happy.

> More importantly, if I might ask for help again... now it's barfing on
> itemprop.cc:

> Error E2232 itemprop.cc 50: Constant member 'armour_def::name' in class
> without constructors
> Error E2232 itemprop.cc 162: Constant member 'weapon_def::name' in
> class without constructors
> Error E2232 itemprop.cc 341: Constant member 'missile_def::name' in
> class without constructors
> Error E2232 itemprop.cc 363: Constant member 'food_def::name' in class
> without constructors

You probably need to change:

struct armour_def
{
armour_type id;
const char name[ITEMNAME_SIZE];

to

struct armour_def
{
armour_type id;
const char *name;

And do the same for weapon_def, missile_def, and food_def. It's
unclear to me why name was defined as a char array at all for those
structs.

--
Darshan Shaligram <scintilla@xxxxxxxxx> Deus vult
.



Relevant Pages

  • Re: To coerce or not...? struct sockaddr vs struct sockaddr_in
    ... that "pointer to struct X" and "pointer to struct Y" are not ... prototype, if it has one -- and apparently it does on your system ... this instructs the compiler to truncate the ".14" part, ... Grabbing an "int", when the compiler passed ...
    (comp.lang.c)
  • Re: komplexes Problem mit Funktionszeigern
    ... Die Funktion gibt einen struct "by value" zurueck und bei der ... am Borland Compiler, da der Microsoft Compiler ... Man kann Argumente fuer eine Funktion z.B auf dem Stack uebergeben. ... Das funktioniert natuerlich nur fuer "Basis Typen" die in ein Register passen. ...
    (de.comp.lang.c)
  • Re: Naming typedefs
    ... problem that a scalar could be returned in the A register ... to have waste precious cpu cycles copying the struct there ... of the hardware or twentieth century compiler technology. ... # to include the header defining it into every other header (assuming ...
    (comp.unix.programmer)
  • Re: assembly language and reverse engineering
    ... "return arguments to struct pointed to by register" and ... assumptions of CDECL-like conventions (also supports STDCALL, ... arg for handling struct return (slightly compiler, and compiler version, ...
    (alt.lang.asm)
  • Re: HardBound and SoftBound (was "The State of Software")
    ... I will explain to you one last time that the problem is not whether a compiler can generate checks for all buffer overflows. ... By the way, in the last example of such code that I saw, it had been changed to use the address of the struct, not of the first element of the struct: ... to take address of struct rather than address of first element. ... such tricks are used to create a pointer which is then passed on. ...
    (comp.arch)