Skip to content

Commit 1f7884e

Browse files
committed
workaround for weird symbol issue on nvc++
1 parent a851257 commit 1f7884e

File tree

7 files changed

+97
-8
lines changed

7 files changed

+97
-8
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,12 @@ template:
2121
2222
-->
2323

24+
## Unreleased
25+
2426
## v3.4.0
2527

28+
- fixed "unresolved symbol" error with nvc++ (#220) (@Tomcat-42)
29+
2630
#### Fixes
2731

2832
- fixed `value_flags` not being preserved correctly when inserting into tables and arrays (#108) (@LebJe)

include/toml++/impl/node.hpp

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,13 @@
99
#include "source_region.hpp"
1010
#include "header_start.hpp"
1111

12+
// workaround for this: https://github.com/marzer/tomlplusplus/issues/220
13+
#if TOML_NVCC
14+
#define TOML_NVCC_WORKAROUND { return {}; }
15+
#else
16+
#define TOML_NVCC_WORKAROUND = 0
17+
#endif
18+
1219
TOML_NAMESPACE_START
1320
{
1421
/// \brief A TOML node.
@@ -246,19 +253,19 @@ TOML_NAMESPACE_START
246253

247254
/// \brief Returns the node's type identifier.
248255
TOML_PURE_GETTER
249-
virtual node_type type() const noexcept = 0;
256+
virtual node_type type() const noexcept TOML_NVCC_WORKAROUND;
250257

251258
/// \brief Returns true if this node is a table.
252259
TOML_PURE_GETTER
253-
virtual bool is_table() const noexcept = 0;
260+
virtual bool is_table() const noexcept TOML_NVCC_WORKAROUND;
254261

255262
/// \brief Returns true if this node is an array.
256263
TOML_PURE_GETTER
257264
virtual bool is_array() const noexcept = 0;
258265

259266
/// \brief Returns true if this node is an array containing only tables.
260267
TOML_PURE_GETTER
261-
virtual bool is_array_of_tables() const noexcept = 0;
268+
virtual bool is_array_of_tables() const noexcept TOML_NVCC_WORKAROUND;
262269

263270
/// \brief Returns true if this node is a value.
264271
TOML_PURE_GETTER
@@ -327,6 +334,8 @@ TOML_NAMESPACE_START
327334
return is_time();
328335
else if constexpr (std::is_same_v<type, date_time>)
329336
return is_date_time();
337+
338+
TOML_UNREACHABLE;
330339
}
331340

332341
/// @}
@@ -452,6 +461,8 @@ TOML_NAMESPACE_START
452461
return as_time();
453462
else if constexpr (std::is_same_v<unwrapped_type, date_time>)
454463
return as_date_time();
464+
465+
TOML_UNREACHABLE;
455466
}
456467

457468
/// \brief Gets a pointer to the node as a more specific node type (const overload).
@@ -481,6 +492,8 @@ TOML_NAMESPACE_START
481492
return as_time();
482493
else if constexpr (std::is_same_v<unwrapped_type, date_time>)
483494
return as_date_time();
495+
496+
TOML_UNREACHABLE;
484497
}
485498

486499
/// @}
@@ -1112,4 +1125,5 @@ TOML_IMPL_NAMESPACE_START
11121125
TOML_IMPL_NAMESPACE_END;
11131126
/// \endcond
11141127

1128+
#undef TOML_NVCC_WORKAROUND
11151129
#include "header_end.hpp"

include/toml++/impl/preprocessor.hpp

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,14 @@
175175
#endif
176176
#endif
177177

178+
#ifndef TOML_NVCC
179+
#ifdef __NVCOMPILER_MAJOR__
180+
#define TOML_NVCC __NVCOMPILER_MAJOR__
181+
#else
182+
#define TOML_NVCC 0
183+
#endif
184+
#endif
185+
178186
//#=====================================================================================================================
179187
//# ARCHITECTURE
180188
//#=====================================================================================================================
@@ -395,6 +403,7 @@
395403
#endif
396404

397405
// TOML_ALWAYS_INLINE
406+
#ifndef TOML_ALWAYS_INLINE
398407
#ifdef _MSC_VER
399408
#define TOML_ALWAYS_INLINE __forceinline
400409
#elif TOML_GCC || TOML_CLANG || TOML_HAS_ATTR(__always_inline__)
@@ -404,8 +413,10 @@
404413
#else
405414
#define TOML_ALWAYS_INLINE inline
406415
#endif
416+
#endif
407417

408418
// TOML_NEVER_INLINE
419+
#ifndef TOML_NEVER_INLINE
409420
#ifdef _MSC_VER
410421
#define TOML_NEVER_INLINE TOML_DECLSPEC(noinline)
411422
#elif TOML_CUDA // https://gitlab.gnome.org/GNOME/glib/-/issues/2555
@@ -418,33 +429,44 @@
418429
#ifndef TOML_NEVER_INLINE
419430
#define TOML_NEVER_INLINE
420431
#endif
432+
#endif
421433

422434
// MSVC attributes
435+
#ifndef TOML_ABSTRACT_INTERFACE
423436
#define TOML_ABSTRACT_INTERFACE TOML_DECLSPEC(novtable)
437+
#endif
438+
#ifndef TOML_EMPTY_BASES
424439
#define TOML_EMPTY_BASES TOML_DECLSPEC(empty_bases)
440+
#endif
425441

426442
// TOML_TRIVIAL_ABI
443+
#ifndef TOML_TRIVIAL_ABI
427444
#if TOML_CLANG || TOML_HAS_ATTR(__trivial_abi__)
428445
#define TOML_TRIVIAL_ABI TOML_ATTR(__trivial_abi__)
429446
#else
430447
#define TOML_TRIVIAL_ABI
431448
#endif
449+
#endif
432450

433451
// TOML_NODISCARD
452+
#ifndef TOML_NODISCARD
434453
#if TOML_CPP >= 17 && TOML_HAS_CPP_ATTR(nodiscard) >= 201603
435454
#define TOML_NODISCARD [[nodiscard]]
436455
#elif TOML_CLANG || TOML_GCC || TOML_HAS_ATTR(__warn_unused_result__)
437456
#define TOML_NODISCARD TOML_ATTR(__warn_unused_result__)
438457
#else
439458
#define TOML_NODISCARD
440459
#endif
460+
#endif
441461

442462
// TOML_NODISCARD_CTOR
463+
#ifndef TOML_NODISCARD_CTOR
443464
#if TOML_CPP >= 17 && TOML_HAS_CPP_ATTR(nodiscard) >= 201907
444465
#define TOML_NODISCARD_CTOR [[nodiscard]]
445466
#else
446467
#define TOML_NODISCARD_CTOR
447468
#endif
469+
#endif
448470

449471
// pure + const
450472
#ifndef TOML_PURE
@@ -494,6 +516,7 @@
494516
#endif
495517

496518
// TOML_ASSUME
519+
#ifndef TOML_ASSUME
497520
#ifdef _MSC_VER
498521
#define TOML_ASSUME(expr) __assume(expr)
499522
#elif TOML_ICC || TOML_CLANG || TOML_HAS_BUILTIN(__builtin_assume)
@@ -505,15 +528,18 @@
505528
#else
506529
#define TOML_ASSUME(expr) static_cast<void>(0)
507530
#endif
531+
#endif
508532

509533
// TOML_UNREACHABLE
534+
#ifndef TOML_UNREACHABLE
510535
#ifdef _MSC_VER
511536
#define TOML_UNREACHABLE __assume(0)
512537
#elif TOML_ICC || TOML_CLANG || TOML_GCC || TOML_HAS_BUILTIN(__builtin_unreachable)
513538
#define TOML_UNREACHABLE __builtin_unreachable()
514539
#else
515540
#define TOML_UNREACHABLE static_cast<void>(0)
516541
#endif
542+
#endif
517543

518544
// TOML_LIKELY
519545
#if TOML_CPP >= 20 && TOML_HAS_CPP_ATTR(likely) >= 201803

include/toml++/impl/table.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1527,6 +1527,8 @@ TOML_NAMESPACE_START
15271527
}
15281528
return iterator{ ipos };
15291529
}
1530+
1531+
TOML_UNREACHABLE;
15301532
}
15311533

15321534
/// \brief Inserts a new value at a specific key if one did not already exist.

include/toml++/impl/toml_formatter.inl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,6 @@ TOML_ANON_NAMESPACE_START
9292
val *= -1.0;
9393
}
9494
return weight + static_cast<size_t>(log10(val)) + 1u;
95-
break;
9695
}
9796

9897
case node_type::boolean: return 5u;

include/toml++/toml.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ TOML_POP_WARNINGS;
184184
#undef TOML_NEVER_INLINE
185185
#undef TOML_NODISCARD
186186
#undef TOML_NODISCARD_CTOR
187+
#undef TOML_NVCC
187188
#undef TOML_OPEN_ENUM
188189
#undef TOML_OPEN_FLAGS_ENUM
189190
#undef TOML_PARSER_TYPENAME

0 commit comments

Comments
 (0)