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

Netbsd: standard integer types are also defined as macros #453

Merged
merged 1 commit into from
Oct 3, 2016

Conversation

fdopen
Copy link
Contributor

@fdopen fdopen commented Sep 29, 2016

Similar to #433

@yallop
Copy link
Owner

yallop commented Oct 3, 2016

I'd like to fix this problem, but I'm not keen on the proposed solution for two reasons: it tests for a particular platform (__NETBSD__) rather than for the availability of the C99 integer types, and it depends on the implementation details of that platform, namely the availability of types such as __uint64_t.

So how about something like the following instead, which should work anywhere that uint64_t etc. are defined as macros?

#ifdef uint64_t
  /* Use the uint64_t macro to define a new typedef */ 
  typedef uint64_t ctypes_uint64_t;    

  /* Use the new typedef to replace the macro definition */ 
# undef uint64_t
  typedef ctypes_uint64_t uint64_t;
#endif

(I realise that I've merged #433, which uses the same technique proposed here. But I'd like to switch the code from that PR over to something more like what I've described above, too.)

Circumvent any problem by passing the size around instead of the type
@fdopen
Copy link
Contributor Author

fdopen commented Oct 3, 2016

netbsd defines uint64_t in both ways: as typdef and as macro:

#ifndef uint64_t
typedef __uint64_t      uint64_t;
#define uint64_t        __uint64_t
#endif

You will end with two typdefs for uint64_t, which is a violation of the C standard (my solution had the same problem).
I've now changed the Uint_custom_val macro. If the size instead of the type is passed around as argument, it doesn't matter, if uint64_t is a macro or not.

@yallop
Copy link
Owner

yallop commented Oct 3, 2016

That's much neater than my suggestion. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants