Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Normalize size_t usage in Fortran #171

Merged
merged 1 commit into from
Jun 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions Examples/test-suite/fortran/typedef_sizet_runme.F90
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
! File : typedef_sizet_runme.F90

#include "fassert.h"

program typedef_sizet_runme
use typedef_sizet
use ISO_C_BINDING
implicit none
integer(C_SIZE_T) :: inp, outp

inp = 1234_c_size_t
outp = identity_size(inp)
ASSERT(inp == outp)
end program
7 changes: 6 additions & 1 deletion Examples/test-suite/typedef_sizet.i
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
%module typedef_sizet

#ifdef SWIGFORTRAN
// Avoid shadowing intrinsic size
%rename("identity_size") size;
#endif

typedef unsigned long long size_t;
%inline %{
size_t size(size_t x) {return x; }
size_t size(size_t x) {return x; }
%}
12 changes: 0 additions & 12 deletions Lib/fortran/fundamental.swg
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,6 @@

%include <typemaps/swigmacros.swg>

#ifdef __cplusplus
namespace std
{
#endif
typedef unsigned long long size_t;
typedef long long ptrdiff_t;
#ifdef __cplusplus
}
using std::size_t;
using std::ptrdiff_t;
#endif

/* -------------------------------------------------------------------------
* FRAGMENTS
* ------------------------------------------------------------------------- */
Expand Down
2 changes: 1 addition & 1 deletion Lib/fortran/std_set.i
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public:
// Typedefs
typedef _Key value_type;
typedef _Key key_type;
typedef std::size_t size_type;
typedef size_t size_type;
typedef ptrdiff_t difference_type;
typedef value_type *pointer;
typedef const value_type *const_pointer;
Expand Down