libgphoto2 photo camera library (libgphoto2) API 2.5.29

Macros
compiletime-assert.h File Reference

Allow compile time assertions with or without C11. More...

Go to the source code of this file.

## Macros
#define | COMPILETIME_ASSERT(CONDITION)
#define | MAKE_BARE_COMPILETIME_ASSERT_NAME
#define | MAKE_BARE_COMPILETIME_ASSERT_NAME1(BASE, PARAM) MAKE_BARE_COMPILETIME_ASSERT_NAME2(BASE, PARAM)
#define | MAKE_BARE_COMPILETIME_ASSERT_NAME2(BASE, PARAM) BASE ## _ ## PARAM
#define | BARE_COMPILETIME_ASSERT(CONDITION)

## Detailed Description

Allow compile time assertions with or without C11.

C11 has added static_assert(EXPR, MSG) to assert.h, but C99 only knows runtime assertions using assert(EXPR). This defines COMPILETIME_ASSERT(EXPR) which works with both C99 and C11 and later.

Author
  Copyright (C) 2010-2021 Hans Ulrich Niedermann hun@n.nosp@m.-dim.nosp@m.ensio.nosp@m.nal..nosp@m.de

Copyright
  GNU Lesser General Public License 2 or later

This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA

## Macro Definition Documentation

## ◆ BARE_COMPILETIME_ASSERT

#define BARE_COMPILETIME_ASSERT | ( |  | CONDITION | ) |

Value:
void MAKE_BARE_COMPILETIME_ASSERT_NAME(void); \
void MAKE_BARE_COMPILETIME_ASSERT_NAME(void) \
{ \
COMPILETIME_ASSERT(CONDITION); \
}

Compiletime assertion for use outside a function.

## ◆ COMPILETIME_ASSERT

#define COMPILETIME_ASSERT | ( |  | CONDITION | ) |

Value:
switch (0) { /* error here means assertion has failed */ \
case 0: /* error here means assertion has failed */ \
case (CONDITION): /* error here means assertion has failed */ \
break; \
}

Compiletime assertion for use inside a function.

## ◆ MAKE_BARE_COMPILETIME_ASSERT_NAME

#define MAKE_BARE_COMPILETIME_ASSERT_NAME

Value:
MAKE_BARE_COMPILETIME_ASSERT_NAME1(COMPILETIME_ASSERT_fails_in_line, \
__LINE__)