Are `typedef` synonyms interchangeable in C?

The ad qboolean SNDDMA_InitDirect (void);appears in 'WinQuake / snd_win.c' on line 69 . However, the function definition (appearing on line 183 of the same file is written as:

sndinitstat SNDDMA_InitDirect (void)
{
    /* Actual implementation is unimportant in this discussion. */
}

Both qbooleanand sndinitstatare typedefenumerations: sndinitstaton line 33 of 'WinQuake / snd_win.c' ,

typedef enum {SIS_SUCCESS, SIS_FAILURE, SIS_NOTAVAIL} sndinitstat;

and qbooleanin 'WinQuake / common.h' (line 30)

typedef enum {false, true} qboolean;

These are various listings .

Visual Studio 2015, - cl.exe - Clang v3.7.1 LLVM Visual Studio. , / . Visual Studio . ?

, C: A Reference Manual ( ):

  • 5.5 (. 127)

    int.

  • 5.10 (. 149)

    typedef ; , .

, , , . , Microsoft C.

+4
2

, typedef qboolean sndinitstat, , . , . (. 6.2.7 ).

, , .

typedef . , . , , , . Visual Studio .

, Clang ( GCC) - , . ,

enum { A1, A2, A3 } foo();
enum { B1, B2, B3 } foo();

Clang GCC, . , , foo .

+1

:

typedef enum {false, true}  qboolean;
typedef enum {SIS_SUCCESS, SIS_FAILURE, SIS_NOTAVAIL} sndinitstat;

6.2.5: 16,

.

, , , .

+3

Source: https://habr.com/ru/post/1627524/


All Articles