Skip to content

Commit

Permalink
Render include paths relative.
Browse files Browse the repository at this point in the history
By removing `etl/` from include paths (in `#include` statements), the path to the directory `include/` doesn't need to be provided to the preprocessor as an include path if the files in `include/etl/` are included by other means.
This has no disadvantages.
Actually the form `#include "..."` is intended to be used for relative paths in the first place.

This is relevant if one wants to include the source files from `include/etl` only indirectly.

For example we use special generated header files which wrap the include statement of the vanilla header files with diagnostic commands.
Those commands allow to disable diagnostic for ETL's files and re-enable them after the file inclusion.
Wrapper files are generated for every non-private header file.
We provide the directory with the wrapper files as include path to the preprocessor instead of the normal `include/` directory.
Thus include statements like `#include "etl/private/..."` are invalid in that case.
  • Loading branch information
dhebbeker committed Apr 9, 2024
1 parent dd060d5 commit 335b361
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions include/etl/limits.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,19 +80,19 @@ SOFTWARE.

#if defined(ETL_NO_CPP_NAN_SUPPORT)
#if defined(NAN)
#include "etl/private/diagnostic_useless_cast_push.h"
#include "private/diagnostic_useless_cast_push.h"
#define ETL_NANF NAN
#define ETL_NAN static_cast<double>(NAN)
#define ETL_NANL static_cast<long double>(NAN)
#define ETL_HAS_NAN true
#include "etl/private/diagnostic_pop.h"
#include "private/diagnostic_pop.h"
#else
#include "etl/private/diagnostic_useless_cast_push.h"
#include "private/diagnostic_useless_cast_push.h"
#define ETL_NANF HUGE_VALF
#define ETL_NAN HUGE_VAL
#define ETL_NANL HUGE_VALL
#define ETL_HAS_NAN false
#include "etl/private/diagnostic_pop.h"
#include "private/diagnostic_pop.h"
#endif
#else
#define ETL_NANF nanf("")
Expand Down
4 changes: 2 additions & 2 deletions include/etl/random.h
Original file line number Diff line number Diff line change
Expand Up @@ -462,12 +462,12 @@ namespace etl

random_pcg()
{
#include "etl/private/diagnostic_useless_cast_push.h"
#include "private/diagnostic_useless_cast_push.h"
// An attempt to come up with a unique non-zero seed,
// based on the address of the instance.
uintptr_t n = reinterpret_cast<uintptr_t>(this);
value = static_cast<uint64_t>(n);
#include "etl/private/diagnostic_pop.h"
#include "private/diagnostic_pop.h"
}

//***************************************************************************
Expand Down

0 comments on commit 335b361

Please sign in to comment.