www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/04/15/23:35:08

Message-ID: <31730086.2007@public1.guangzhou.gd.cn>
Date: Tue, 16 Apr 1996 11:05:58 +0900
From: Wang TianXing <gztxwang AT public1 DOT guangzhou DOT gd DOT cn>
Organization: No Organization
MIME-Version: 1.0
To: malcolm AT manawatu DOT gen DOT nz
CC: djgpp AT delorie DOT com
Subject: Re: dir.h problem
References: <199604121413 DOT KAA20749 AT delorie DOT com> <4kt899$njn AT news DOT manawatu DOT gen DOT nz>

Malcolm Taylor wrote:
> 
> This is a known bug in the gcc2.7.2 sources. When compiling with C++
> structures with the packed attribute on their members don't get packed
> properly. One solution is to compile the code that requires findfirst
> and findnext in C (I have used this soln). However a better solution
> is to edit the dir.h file (I think, the one with struct ffblk) and
> add:
> 
> #ifdef __cplusplus
> #pragma pack(1)
> #endif
> 
> struct ffblk ...
>     ...
> 
> #ifdef __cplusplus
> #pragma pack(0)
> #endif
>
> Which will fix the problem (if there is an error in the above then
> feel free to correct me :)

This is a known G++ 2.7.2 bug.  But I don't think one has to use
#ifdef __cplusplus things.  Simply put #pragma whatever there, it
should also work with the C compiler.

G++ complains to #pragma pack(0) that:

warning: malformed `#pragma pack'

I think you might have to use pack() instead.

Instead of changing <dir.h>, one can use it this way:

#pragma pack(1)
#include <dir.h>
#pragma pack()

There's no danger to do this with <dir.h>.

Does anyone know where the description of those #pragma's is?
>From the info files, I can only realize that Stallman doesn't
like #pragma's.

> Whenever gcc 2.7.3 comes out this problem will no longer exist.

How do you know that?  Do you know what new bugs will creep out? :)

> Malcolm

Regards,
Wang TianXing

- Raw text -


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