what is this define thing between struct in c

Thread Starter

bug13

Joined Feb 13, 2012
2,002
Hi guys,

Here is the code:
Code:
#ifndef __RFC_STRUCT
#define __RFC_STRUCT
#endif

// other codes removed

//! \addtogroup rfc
//! @{

//! \addtogroup data_entry
//! @{

#include <stdint.h>
#include "rf_mailbox.h"

typedef struct __RFC_STRUCT rfc_dataEntry_s rfc_dataEntry_t;
typedef struct __RFC_STRUCT rfc_dataEntryGeneral_s rfc_dataEntryGeneral_t;
typedef struct __RFC_STRUCT rfc_dataEntryMulti_s rfc_dataEntryMulti_t;
typedef struct __RFC_STRUCT rfc_dataEntryPointer_s rfc_dataEntryPointer_t;
typedef struct __RFC_STRUCT rfc_dataEntryPartial_s rfc_dataEntryPartial_t;
What is this __RFC_STRUCT for?
 

402DF855

Joined Feb 9, 2013
271
It's a placeholder for adding attributes as required by the part and or compiler etc.
C:
#ifndef __RFC_STRUCT
#ifdef __GNUC__
#define __RFC_STRUCT __attribute__ ((aligned (4)))
#else
#define __RFC_STRUCT
#endif
#endif
 

nsaspook

Joined Aug 27, 2009
16,257
If __RFC_STRUCT is already defined it's used as a GNUC attribute (or nothing for other type compilers) for the type of structure created otherwise it's a null string that does nothing.

Typical example maybe in a header somewhere that's included in the code.

#ifndef __RFC_STRUCT
#ifdef __GNUC__
#define __RFC_STRUCT __attribute__ ((aligned (4)))
#else
#define __RFC_STRUCT
#endif
#endif

Looks like a structure variable element 32-bit alignment attribute.
https://gcc.gnu.org/onlinedocs/gcc-4.0.4/gcc/Type-Attributes.html

EDIT: Just a little slow today.
 

nsaspook

Joined Aug 27, 2009
16,257
It's a placeholder for adding attributes as required by the part and or compiler etc.
C:
#ifndef __RFC_STRUCT
#ifdef __GNUC__
#define __RFC_STRUCT __attribute__ ((aligned (4)))
#else
#define __RFC_STRUCT
#endif
#endif
You would think he could have looked this up in about 30 seconds.:D
 
Top