ERLEDIGT
JA
JA
ANTWORTEN
1
1
ZUGRIFFE
143
143
EMPFEHLEN
-
08.08.11 21:46 #1
- Registriert seit
- Jun 2007
- Ort
- Irgendwo in der Milchstraße
- Beiträge
- 38
Hallo!
Ich habe ein kleines Problem mit einem struct.
Der TgxHeader stimmt soweit (8 Byte), jedoch beim BmpHeader wird mir immer mit sizeof() eine falsche Größe geliefert. (16 statt 14).
Eigentlich sollte 1x short(2Byte) + 3x int(4Byte) ja 14 ergeben !?
Getestet wurde folgender Code sowohl mit dem Visual C++ 2010 unter Windows 7 als auch dem GCC 4.5.2 unter Ubuntu (32 Bit).
Code :1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
#include <stdio.h> typedef struct __bmpHeader{ short bfType; int bfSize; int bfReserved; int bfOffBits; }BmpHeader; typedef struct __tgxHeader { short width; short nothing1; short height; short nothing2; }TgxHeader; int main(void){ printf("sizeof(short): %d, sizeof(int): %d\n", sizeof(short), sizeof(int)); printf("sizeof(BmpHeader): %d\n", sizeof(BmpHeader)); printf("sizeof(TgxHeader): %d\n", sizeof(TgxHeader)); return 0; }
Die Ausgabe:
Code :1 2 3
sizeof(short): 2, sizeof(int): 4 sizeof(BmpHeader): 16 sizeof(TgxHeader): 8
Ich hoffe jemand von euch Profis kann mir helfen Oo
Danke im vorhinein.Mein System:
iMac 24"
MacBook ALU 2,4GHz
PC:
CPU: Intel Core2Quad Q6600 (2,4 GHz)
RAM:6GB
Festplatte: 500GB
GraKa: nVidia Geforce 9800GTX
Betriebssytem: Windows 7 Ultimate x64 SP 1, Ubuntu 11.04
-
08.08.11 22:30 #2
- Registriert seit
- Jun 2007
- Ort
- Irgendwo in der Milchstraße
- Beiträge
- 38
Nach langem fehlersuchen bin ich dann auf
Code :1
#pragma pack(1)
gestoßen. Anscheinen versucht der Compiler hier zu optimieren, was er nicht soll !?
Naja, jetzt gehtsMein System:
iMac 24"
MacBook ALU 2,4GHz
PC:
CPU: Intel Core2Quad Q6600 (2,4 GHz)
RAM:6GB
Festplatte: 500GB
GraKa: nVidia Geforce 9800GTX
Betriebssytem: Windows 7 Ultimate x64 SP 1, Ubuntu 11.04
Ähnliche Themen
-
Liste für 2 Structs
Von Need_Name im Forum C/C++Antworten: 8Letzter Beitrag: 04.01.10, 14:49 -
C++ structs lesen
Von Orthak im Forum C/C++Antworten: 7Letzter Beitrag: 13.01.09, 21:21 -
Spinnen Animation
Von juergimat im Forum 3D Studio MaxAntworten: 6Letzter Beitrag: 09.09.07, 23:09 -
Uploadprotokolle spinnen
Von iNstinct im Forum Internet, DSL & FlatrateAntworten: 0Letzter Beitrag: 08.08.06, 12:04 -
Codecs spinnen!
Von Xo-mate im Forum Videoschnitt, Videotechnik & -produktionAntworten: 1Letzter Beitrag: 10.08.05, 22:47





Zitieren
Login






