From: <no...@so...> - 2002-09-25 09:19:53
|
Bugs item #614067, was opened at 2002-09-24 22:52 You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=102435&aid=614067&group_id=2435 Category: MinGW Group: None Status: Open Resolution: None Priority: 5 Submitted By: Dave Spring (dspring) Assigned to: Earnie Boyd (earnie) Summary: need pack/alignment attribute in stat.h Initial Comment: MingGW 2.0.0 using gcc -fpack-struct breaks stuff. My particular problem is sts/stat.h the alignment for st_rdev gets overriden. MSVCRT clearly uses quadbyte alignment for stat. The fix is somewhere around lines 113,129 - change to: short st_gid ; /* Group: Ditto */ _dev_t st_rdev __attribute__ ((aligned (4))); /* Seems useless (not even filled in) */ _off_t st_size; /* File size in bytes */ twice for stat and _stat It might be worth scheduling a review for other structures. test program/demonstration attached. Oh yes - the symptom is that file sizes are gibberish, since mingw thinks that st_size starts 2 bytes earlier due to the pack-struct. ---------------------------------------------------------------------- >Comment By: Dave Spring (dspring) Date: 2002-09-25 10:19 Message: Logged In: YES user_id=229348 I have read the doc. I'm trying to port libdvdread to win32. So have to match legacy binary files. Hence I don't want to adorn someone else's header files with GCC/Mingw specific #pragma or __attribute__. In a new program I would workaround it by compiling the packed stuff separately and making sure it doesn't invoke any libraries. Anyway, the point is that the mingw header files don't accurately describe the interface to the lib files (including the alignment) which is their sole purpose. I you disagree. Fine. Please at least put an entry in the FAQ with the symptom to help others. ---------------------------------------------------------------------- Comment By: Danny Smith (dannysmith) Date: 2002-09-25 00:30 Message: Logged In: YES user_id=11494 Have you read the doc's for -fpack-struct? -fpack-struct Pack all structure members together without holes. Usually you would not want to use this option, since it makes the code suboptimal, and the offsets of structure members won't agree with system libraries. in new gcc, the warning is slightly different: [from invoke.texi] @strong{Warning:} the @option{-fpack-struct} switch causes GCC to generate code that is not binary compatible with code generated without that switch. Additionally, it makes the code suboptimial. Use it to conform to a non-default application binary interface. Danny ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=102435&aid=614067&group_id=2435 |