Mail Archives: djgpp/1996/08/30/18:49:14
Xref: | news2.mv.net comp.os.msdos.djgpp:8075
|
From: | "Mike Marcelais" <michmarc AT microsoft DOT com>
|
Newsgroups: | comp.os.msdos.djgpp
|
Subject: | Re: struct ffblk bug in C++ ?
|
Date: | 30 Aug 1996 16:23:13 GMT
|
Organization: | Microsoft Corporation
|
Lines: | 34
|
Message-ID: | <01bb9690$3b7faa20$ba27379d@michmarc2>
|
References: | <01bb95f3$71842da0$529033c2 AT megar DOT fc-net DOT fr>
|
NNTP-Posting-Host: | 157.55.39.186
|
To: | djgpp AT delorie DOT com
|
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp
|
| #include <dir.h>
| #include <stdio.h>
| main()
| {
| int s;
| struct ffblk dta;
| s=findfirst("*.*",&dta,0x10);
| while(s!=0)
| { printf("%s\n",dta.ff_name);
| s=findnext(&dta);
| }
| }
|
| It works perfectly when compiled in C (TEST.C)
| But when I rename it to TEST.CPP, the program doesn't work: the first two
| letters of ALL entries are missing !!
| I think that it is a bug in the declaration of the ffblk struct. Did you
| ever found this problem ?
Actually, I read here that it is a known problem with the C++ compiler. The
fix is to provide `wrapper' functions for all of the fields in the findfirst
structure in a C compiled file and use those functions to access the fields.
[My guess: DJGPP C++ does not pack structures by default like C does, and the
ffblk structure is probably laid out non-ideally, so C++ pads it for speed.]
--
+------------------------+----------------------+
| Mike Marcelais | Excel Developer and |
| michmarc AT microsoft DOT com | Magic Rules Guru |
+------------------------+----------------------+
| Opinions expressed in this post are mine, and |
| do not necessarily reflect those of Microsoft |
+--= Moonstone Dragon =---------------= UDIC =--+
- Raw text -