Skip to content

Commit eaa99b0

Browse files
committed
Improve import code robustness
1 parent c21dfbe commit eaa99b0

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

include/flc.i

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77

88
%module "flc"
99

10+
#if defined(SWIGIMPORTED) && !defined(SWIGIMPORTED)
11+
#error "To import the FLC module correctly, use ``%include \"import_flc.i\"``"
12+
#endif
13+
1014
%define %flc_add_header
1115
%insert("fbegin") %{
1216
! Flibcpp project, https://github.com/swig-fortran/flibcpp

include/import_flc.i

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@
55
* Distributed under an MIT open source license: see LICENSE for details.
66
*/
77

8-
#ifdef SWIGIMPORTED
9-
#error "To use this header, %include "import_flc.i", don't %import it"
8+
// Make sure that the downstream module isn't doing ``%import "import_flc.i"``
9+
// or ``%import "flc.i"``: only ``%include "import_flc.i"``
10+
#ifndef SWIGIMPORTED
11+
#define FLC_SWIGIMPORTED
1012
#endif
1113

1214
// Set up macros, etc.

0 commit comments

Comments
 (0)