www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/06/03/03:54:13

Sender: Jorrit DOT Tyberghein AT uz DOT kuleuven DOT ac DOT be
Message-Id: <31B2997B.4A7D@uz.kuleuven.ac.be>
Date: Mon, 03 Jun 1996 09:51:23 +0200
From: Jorrit Tyberghein <Jorrit DOT Tyberghein AT uz DOT kuleuven DOT ac DOT be>
Organization: Universitaire Ziekenhuizen Leuven
Mime-Version: 1.0
To: DJGPP AT delorie DOT com
Subject: Bug in findfirst/findnext???

Hi,

I had a program that worked fine in DJGPP 2.0beta3. Recently (the
previous week) I upgraded to the non-beta version of DJGPP 2.0.
I encountered the following problem. The following program (note,
I'm typing this program from my head, there could be some mistakes
in it):

   #include <stdio.h>
   #include <dir.h>

   int main (int argc, char* argv[])
   {
     struct ffblk ff;
     int rc;
     rc = findfirst ("*.*", &ff, ~0);
     while (rc)
     {
       printf ("%s\n", ff.fa_name);
       rc = findnext (&ff);
     }
     return 0;
   }

When I compile this program with 'gcc -o test test.c' it works
perfectly and gives the output as expected (a primitive directory
listing).

But when I compile this program with 'gcc -x c++ -o test test.c'
(so I'm using the C++ compiler) it doesn't work correctly anymore.
In the output the two first characters are missing. I have to change
the printf line to 'printf ("%s\n", ff.fa_name-2);' to get the
correct output.

Using 'gcc -o test test.cc' doesn't work either (note the extension).

Apparantly there seems to be something going wrong in the padding
of the ffblk structure defined in 'dir.h' when using the C++
compiler. Maybe this is a bug in the C++ compiler. Has anyone
encountered this bug before? Is there an easy fix (apart from looking
two bytes to the left of fa_name of course :-)

And no, there are NO include files left from the previous version
of DJGPP. I deleted the entire DJGPP directory structure before
installing the new version. I also replaced the old CWSDPMI.EXE
with the new one in case you are wondering (but I doubt this will
have anything to do with it).

My system:
   Pentium with 16M
   DOS 7.0 (Window 95)
   LFN=n (in DJGPP.ENV)
   DJGPP 2.0 (latest version, only downloaded one week ago)
   GCC 2.7.2 included with DJGPP.

Greetings and many thanks in advance,

-- 
==============================================================================
Jorrit DOT Tyberghein AT uz DOT kuleuven DOT ac DOT be, University Hospitals KU Leuven BELGIUM

People who used magic without knowing what they were doing usually came to
a sticky end. All over the entire room, sometimes.
        -- (Terry Pratchett, Moving Pictures)
==============================================================================

- Raw text -


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