peinliche Frage!?
-
Kindergarten :p
-
Also das mit dem int läuft so. Auf einem 16-Bit Betriebssystem (z.B. DOS) ist der 2 Byte groß, weil 2 Byte = 16 Bit. Auf einem 32-Bit Betriebssystem ist der Integer 32 Bit groß, also 4 Byte.
Deshalb meine allgemeine Empfehlung, nutze int so selten wie möglich, insbesondere bei Plattformübergreifender Programmierung, lieber long, der ist nämlich überall 32 Bit groß.
-
Auch demnächst auf 64 Bit Plattformen??? Und int dann?
Aber geiles Thema und nichs peinlich. Vor kurzem habe ich meinen hochgestochenen "Dipl-Ing Arbeitskollegen ich weiß alles" damit auflaufen lassen.
gruß pt
-
plc_tippser schrieb:
Auch demnächst auf 64 Bit Plattformen??? Und int dann?
gruß pt
deshalb seine eigenen typen definieren
INT16
INT32
INT64
UINTblablabla usw. dann kann das nicht passieren, und man ist auf jeder win plattform unanhaengig
-
uebringens, was hat das mit MFC zu tun??
-
also.....
mit mfc hat das recht viel zu tun da es mir in der msdn dazu aufgefallen ist
jedoch hast du natuerlich recht dass ich auch woanders danach fragen koennte wo es um grundlagen geht...(nicht boese gemeint)was ich aber immer noch nicht beantwortet bekommen habe ist folgendes:
warum sagt die msdn meistens dass der jeweilige rueckgabewerte int ist und heute hab ich dann ein long gefunden (dateien einladen, long = 2GB adressierbar)
wenn ich dann aber auf so manche grundlagenseite schaue oder in buecvhern waelze finde ich immer wieder long inthandelt es sich also hier bei int rueckgabewerten um werte bis 32767 und bei longs dann um 2milliarden und wenn es sich nicht um rueckgabewerte sondern um variablen handelt dann ist int eigentlich long int wird aber nicht so genannt und ich kann 2milliarden reinpacken?
gruss
Guenni
-
also die MSDN sagt mir
-----------------------
The size of a signed or unsigned int item is the standard size of an integer on a particular machine. For example, in 16-bit operating systems, the int type is usually 16 bits, or 2 bytes. In 32-bit operating systems, the int type is usually 32 bits, or 4 bytes. Thus, the int type is equivalent to either the short int or the long int type, and the unsigned int type is equivalent to either the unsigned short or the unsigned long type, depending on the target environment. The int types all represent signed values unless specified otherwise.The type specifiers int and unsigned int (or simply unsigned) define certain features of the C language (for instance, the enum type). In these cases, the definitions of int and unsigned int for a particular implementation determine the actual storage.
Microsoft Specific —>
Signed integers are represented in two's-complement form. The most-significant bit holds the sign: 1 for negative, 0 for positive and zero. The range of values is given in the table Limits on Integer Constants, which is taken from the LIMITS.H header file.
END Microsoft Specific
Note The int and unsigned int type specifiers are widely used in C programs because they allow a particular machine to handle integer values in the most efficient way for that machine. However, since the sizes of the int and unsigned int types vary, programs that depend on a specific int size may not be portable to other machines. To make programs more portable, you can use expressions with the sizeof operator (as discussed in The sizeof Operator) instead of hard-coded data sizes.
-----------------------------------und
-----------------------------------
The keyword int specifies a 32-bit signed integer on 32-bit platforms. On 16-bit platforms, the keyword int is an optional keyword that can accompany the keywords small, short, and long.[ signed | unsigned ] integer-modifier [ int ] declarator-list;
Parameters
integer-modifier
Specifies the keyword small, short, long, hyper, __int3264, or __int64,which selects the size of the integer data. On 16-bit platforms, the size qualifier must be present.
declarator-list
Specifies one or more standard C declarators, such as identifiers, pointer declarators, and array declarators. (Function declarators and bit-field declarations are not allowed in structures that are transmitted in remote procedure calls. These declarators are allowed in structures that are not transmitted.) Separate multiple declarators with commas.
Return Values
This control code's function has no return values.
Remarks
Integer types are among the base types of the interface definition language (IDL). They can appear as type specifiers in typedef declarations, general declarations, and function declarators (as a function-return-type specifier and as a parameter-type specifier). For the context in which type specifiers appear, see Interface Definition (IDL) File.If no integer sign specification is provided, the integer type defaults to signed.
DCE IDL compilers do not allow the keyword signed to specify the sign of integer types. Therefore, this feature is not available when you use the MIDL compiler /osf switch.
Microsoft does not recommend the use of __int3264 for remoting if it can be avoided. Please see the topic on __int3264 for more information regarding it's use and limitations.
--------------------------------
ALSO ist entweder 16 oder 32 bit ( bei deiner kiste 32 ) ok???
und long ist IMMER 32 bit
siehe dazu:
---------------------------------------
The long keyword designates a 32-bit integer.
[ signed | unsigned ] long [ int ] declarator-list;
Parameters
declarator-list
Specifies one or more standard C declarators, such as identifiers, pointer declarators, and array declarators. (Function declarators and bit-field declarations are not allowed in structures that are transmitted in remote procedure calls. These declarators are allowed in structures that are not transmitted.) Separate multiple declarators with commas.
Return Values
This control code's function has no return values.
Remarks
The long keyword can be preceded by either the keyword signed or the keyword unsigned. The int keyword is optional and can be omitted. To the MIDL compiler, a long integer is signed by default and is synonymous with signed long int. On 32-bit platforms, long is synonymous with int.The long integer type is one of the base types of the IDL language. The long integer type can appear as a type specifier in const declarations, typedef declarations, general declarations, and function declarators (as a function return–type specifier and as a parameter-type specifier). For the context in which type specifiers appear, see Interface Definition (IDL) File.
---------------------------------------
also noch fragen???????
long immer 32 bit
int 16 oder 32 ( aber bei unseren systemen 32 bit sprich 4 milliarden nochwas (( als zahl ))
also 4 mill = insgesamt sprich minus 2 milliarden nochwas bis plus 2 milliarden nochwas
ich hoffe jetzt ist es fuer dich geklaert. schoenes wochenende noch
und MSDN hat nichts mit mfc zu tun ( soweit ich weiss gilt msdn fuer alle MS programme auch visual basic usw. )
-
newkind hat Recht. MSDN sagt: Größe von int ist Platformabhängig. Sprich genau das was newkind gesagt hat, der Rest kann eigentlich nicht sein.
-
pfffffffttt........
schwere kost!! dieses englisch

das bestaetigt ja voll meine theorie (16 & 32 Bit Systeme war mir schon bewusst..ich habs nur euch ueberlassen darueber zu reden...ich denke an was anderes) aber beantwortet soweit ich das verstanden habe nicht die rueckgabewerte
aber ich glaube es ist so dass auch die rueckgabewerte bis signed 2milliarden gehen und ....ach was weiss ich....!!!!

und natuerlich hast du recht dass die msdn nicht nur fuer mfc ist aber ich rufe sie auf weil ich eine mfc anwendung tippe
also hat sie was damit zu tun
ich glaub hier sollten wir uns dann langsam aufs wochenende vorbereiten
schoenes wochenende

Guenni
-
Guenter Mies schrieb:
pfffffffttt........
das bestaetigt ja voll meine theorie (16 & 32 Bit Systeme war mir schon bewusst..ich habs nur euch ueberlassen darueber zu reden...ich denke an was anderes) aber beantwortet soweit ich das verstanden habe nicht die rueckgabewerte
Guenni
warum soll auf einmal bei rueckgabenwerten dies anders sein? ist genau das selbe, oder soll aufeinmal bei rueckgabe nur 2 byte sein
hehe und kauf dir ein gescheites buch, bei meiner c++ referenz wird drauf eingegangen.
und was die MSDN sagt zu den reuckgaben ist ja auch klar. wenn du nur int definierst dann ist es wieder rechner ( bits maessig ) abhangig ausser du machst sowas wie
short int meinefkt( int x)
return meinezahl; // der rueckgabewert ist dann short int
int meinefkt2 ( int x)
return meinezahl; // hier ist es rechnerabhaengig aber signed ( -2 bis +2 milliarden bei dir auf "ibm kompatiblen stand. alsi pc )hier noch die msdn referenz
------------- MSDN
If no integer sign specification is provided, the integer type defaults to signed.
--------------ich hoffe jetzt kannst du beruhigt ins wochenende starten, und zerbrichts dir nicht mehr den kopf darueber
-
tut mir leid aber ich denke du hast nicht wirklich verstanden worüber ich mir den kopf zerbreche
deine rueckschluesse sind voll ok und natuerlich richtig
aber nicht mein problem
ich weiss aber leider auch nicht wie ich es erklaeren soll
es ist aber eigenartig dass microsoft gleiche dinge anders benennt
und nu is gleich 5...backup...wochenende

Guenni
-
Guenter Mies schrieb:
ich weiss aber leider auch nicht wie ich es erklaeren soll
es ist aber eigenartig dass microsoft gleiche dinge anders benennt
Guenni
tut MS nicht
long = long
int = intsoll MS jetzt int rausnehmen wenn man auf 32bitter programiert???? nein
"schuld" ist C
bei java glaube ich, sind die typen fest vorgegeben ( wg. plattformunabhaegigkeit ) bei c ( oder c++ ) halt nicht.
hat nichts mit MS zu tun. wenn du DEV++ nimmst hast du das gleiche "problem"
also ich mach jetzt auch schluss, schoenes wochende, ich hoff der verkehr spinnt nicht verrueckt
PS. das beste ist der letzte satz deines posts ( der letzte meine ich )
das feallt mir nur ein
"schoen das du ein long gefunden hast, welches bis 2 milliarden adress. ist" hehe