LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   a bug in tls.h (https://www.linuxquestions.org/questions/programming-9/a-bug-in-tls-h-377420/)

cigarstub 10-27-2005 11:34 AM

a bug in tls.h
 
Is it the same:
typedef union song
{
size_t albumNo;
void *artist;
} songName;

AND

typedef union
{
size_t albumNo;
void *artist;
} songName;
Are them the same ??
Please explain what size_t corresponds??

naf 10-27-2005 12:04 PM

They are the same. The only difference is that the name song is used for the first union and the second union is unnamed. That difference is insignificant because both forms are typdefing the unions to a given type name.

size_t is platform specific, however, most platforms typedef this field as long unsigned integer. On my system, it is defined as:

# 214 "/usr/lib/gcc/x86_64-redhat-linux/4.0.1/include/stddef.h" 3 4
typedef long unsigned int size_t;

cigarstub 10-27-2005 09:14 PM

QUOTES
# 214 "/usr/lib/gcc/x86_64-redhat-linux/4.0.1/include/stddef.h" 3 4

cOULD you explain the above ?

naf 10-27-2005 09:48 PM

That shows what line from which file the given source code was seen.
In this particular case, the definition was in a file called:
/usr/lib/gcc/x86_64-redhat-linux/4.0.1/include/stddef.h
This file is part of the gcc compiler header files in the standard includes. This compiler is called gcc (GNU C Compiler) targeted for code generation on an Athlon64 (x86_64) system and is version 4.0.1.
That line starting with the # mark is the result of only pre-processing the C source file including <stdio.h>. I only extracted the two pertinent lines for you (the full contents is large).

Pre-processing occurs prior to compilation where all those preprocessor directives (lines that start with the # symbol like #include, #if... #endif, #define, etc. ) are interpreted and the source file is converted to a readable source file that the compiler can parse. This phase is done automatically when you compile, but you can usually specify only preprocess to the compiler for debugging purposes or if you write tools to analyze the processed C code.

A little long winded, but I have a feeling you wanted more detail anyway.

cigarstub 10-27-2005 11:08 PM

So 3 4 means ?

naf 10-28-2005 10:13 AM

Quote:

Originally posted by cigarstub
So 3 4 means ?
That is from the GNU preprocessor. They are flags from the preprocessor to the compiler. These are not a standard C compiler flags.

Briefly, it 3 means the following text comes from a system header file, so certain warnings should be suppressed. The 4 means the following text should be treated as being wrapped in an implicit extern "C" block. To be explict, the following lines are the text lines following the # directive upto the next # directive indicating another file.

Check out the doc http://gcc.gnu.org/onlinedocs/cpp/Pr...ocessor-Output for more information.


All times are GMT -5. The time now is 10:37 PM.