Open Lighting Architecture 0.10.9
Loading...
Searching...
No Matches
Macro.h File Reference

Detailed Description

Helper macros.

Go to the source code of this file.

Macros

#define DISALLOW_COPY_AND_ASSIGN(TypeName)
 Creates dummy copy constructor and assignment operator declarations.
 
#define OLA_UNUSED
 Mark unused arguments & types.
 
#define OLA_FALLTHROUGH
 Mark switch cases as fallthrough when required.
 
#define STATIC_ASSERT(x)
 Compile time assert().
 
#define PACK(__Declaration__)
 Pack structures.
 

Macro Definition Documentation

◆ DISALLOW_COPY_AND_ASSIGN

#define DISALLOW_COPY_AND_ASSIGN ( TypeName)
Value:
TypeName(const TypeName&); \
void operator=(const TypeName&)

Creates dummy copy constructor and assignment operator declarations.

Use this in the private: section of a class to prevent copying / assignment.

Example
class Foo {
public:
Foo() { ... }
private:
Foo(const Foo &) = delete;
const Foo &operator=(const Foo &) = delete;
};

◆ OLA_FALLTHROUGH

#define OLA_FALLTHROUGH

Mark switch cases as fallthrough when required.

Note
We are not currently using [[fallthrough]]; because we need C++98 compatibility
Example
switch (cond) {
case 'foo':
doFoo();
// after foo fallthrough to bar because $REASON
case 'bar':
#define OLA_FALLTHROUGH
Mark switch cases as fallthrough when required.
Definition Macro.h:89

◆ OLA_UNUSED

#define OLA_UNUSED

Mark unused arguments & types.

Example
void Foo(OLA_UNUSED int bar) {}
OLA_UNUSED typedef int Baz;
#define OLA_UNUSED
Mark unused arguments & types.
Definition Macro.h:63

◆ PACK

#define PACK ( __Declaration__)
Value:
__Declaration__ __attribute__((__packed__))

Pack structures.

In order to account for platform differences with regard to packing, we need to use the following macro while declaring types that need to have a specific binary layout. Taken from: http://stackoverflow.com/questions/1537964/ visual-c-equivalent-of-gccs-attribute-packed

Example
struct foo_s {
uint16_t bar;
});
#define PACK(__Declaration__)
Pack structures.
Definition Macro.h:171

◆ STATIC_ASSERT

#define STATIC_ASSERT ( x)
Value:
extern int __dummy[static_cast<int>x]

Compile time assert().

Example
struct foo_s {
uint16_t bar;
});
STATIC_ASSERT(sizeof(foo_s) == 2);
#define STATIC_ASSERT(x)
Compile time assert().
Definition Macro.h:131