Voila mon probleme, je n'arrive pas a definir la taille de mes structures, ce qui est problematique pour certaines operations.

Mon compilo est un mingw.

Code : S�lectionner tout - Visualiser dans une fen�tre � part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
int main () {
	struct struct1 {
		unsigned short type;
	};
	struct struct2 {
		unsigned long fileSize;
	};
	struct struct3 {
		unsigned short type;
		unsigned short fileSize;
	};
	struct struct4 {
		unsigned short type;
		unsigned long fileSize;
	};
	struct struct5 {
		unsigned long type;
		unsigned long fileSize;
	};
	struct struct6 {
		unsigned char type;
		unsigned char fileSize;
	};
	struct struct7 {
		unsigned char type;
		unsigned short fileSize;
	};
	struct struct8 {
		unsigned char type;
		unsigned long fileSize;
	};
 
 
	std::cout << sizeof(struct struct1) << '\n';
	std::cout << sizeof(struct struct2) << '\n';
	std::cout << sizeof(struct struct3) << '\n';
	std::cout << sizeof(struct struct4) << '\n';
	std::cout << sizeof(struct struct5) << '\n';
	std::cout << sizeof(struct struct6) << '\n';
	std::cout << sizeof(struct struct7) << '\n';
	std::cout << sizeof(struct struct8) << '\n';
	return 0;
}
le resultat :
On dirait qu'il "aligne" la taille du plus petit type sur le plus grand.

Je doit avouer etre un peut paum�, ce que je croyais etre absolu ne l'est plus

Une explication ? Une solution ?


edit: Voila ce que j'ai trouv� :
Mauvais design. Une structure C n'est absolument pas faite pour mapper un
flux de bytes (la preuve).