delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/08/12/23:07:58

From: "John M. Aldrich" <fighteer AT cs DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Perculiar bug fix?
Date: Tue, 12 Aug 1997 20:56:22 +0000
Organization: Two pounds of chaos and a pinch of salt
Lines: 46
Message-ID: <33F0CDF6.1B9D@cs.com>
References: <33EEE76F DOT 2F4B904 AT NO_SPAMccds DOT cc DOT monash DOT edu>
Reply-To: fighteer AT cs DOT com
NNTP-Posting-Host: ppp105.cs.com
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Lyle wrote:
> 
> I have recenlty come across a perculiar occurence. I posted a message
> with an "unexplainable" sigsegv fault. Sure, i knew it had to be
> something with my program but what? Well the explanation is quite
> trivial. For some reason, the DJGPP compiled version wasn;t reading my
> configuration files properly. The configuration files were written by
> the exact same code, compiled under Borland TC++ V3.0? Is this normal?
> Is there something i;m doing wrong (most certainly!).

It's definitely something you're doing wrong, but probably something you
haven't ever encountered before when working with DOS-based compilers. 
Read chapter 22.9 of the FAQ for the most comprehensive discussion, but
basically, 32-bit compilers will often align struct members on 2- or
4-byte boundaries in order to improve bus performance, and therefore
program speed.  You can explicitly instruct gcc to pack structures to
make them take the minimum possible size.

You may also be overlooking the fact that DJGPP, as a 32-bit compiler,
uses 32-bit integers.  Any integer variables in the configuration struct
will have to be changed to 'short' to make them compatible with the
16-bit Turbo C integers.

Finally, it's usually best to store configuration information in text
format.  This ensures that it will be portable between compilers and/or
operating systems (some of which may even use a different byte order to
store integers!).

> I still also have the problem that i cannot debug any of my code that i
> have '#include' into modules? Do i have to link all my source files,
> instead of just all my modules?

You should always try to avoid putting actual code into header files. 
This is a very bad practice, even though the real problem is an inherent
limitation of the debugging format used by DJGPP, which only permits one
source file per object file.

hth

-- 
---------------------------------------------------------------------
|      John M. Aldrich       | "Sin lies only in hurting other      |
|       aka Fighteer I       | people unnecessarily.  All other     |
|   mailto:fighteer AT cs DOT com   | 'sins' are invented nonsense."       |
| http://www.cs.com/fighteer |                 - Lazarus Long       |
---------------------------------------------------------------------

- Raw text -


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