Skip to content

warnings building tskit with Ming64 on Windows #1741

@bhaller

Description

@bhaller

@rdinnager reports the following warnings when building tskit (actually tskit's code inside SLiM, but it's the same code) on Windows using the Ming64 compiler:

F:/SLiM/treerec/tskit/core.c: In function 'get_random_bytes':
F:/SLiM/treerec/tskit/core.c:47:29: warning: initialization of 'HCRYPTPROV' {aka 'long long unsigned int'} from 'void *' makes integer from pointer without a cast [-Wint-conversion]
   47 |     HCRYPTPROV hCryptProv = NULL;
      |                             ^~~~
F:/SLiM/treerec/tskit/core.c:57:20: warning: assignment to 'HCRYPTPROV' {aka 'long long unsigned int'} from 'void *' makes integer from pointer without a cast [-Wint-conversion]
   57 |         hCryptProv = NULL;
      |                    ^
F:/SLiM/treerec/tskit/core.c:60:16: warning: assignment to 'HCRYPTPROV' {aka 'long long unsigned int'} from 'void *' makes integer from pointer without a cast [-Wint-conversion]
   60 |     hCryptProv = NULL;
      |                ^
F:/SLiM/treerec/tskit/core.c:63:20: warning: comparison between pointer and integer
   63 |     if (hCryptProv != NULL) {
      |                    ^~

According to the Microsoft docs (https://docs.microsoft.com/en-us/windows/win32/seccrypto/hcryptprov) HCRYPTPROV is supposed to be a pointer to unsigned long:

typedef ULONG_PTR HCRYPTPROV;

It looks like whatever headers are coming from Russell's toolchain define it as long long unsigned int instead; I have no idea why. I would suggest that maybe tskit ought to change those four assignments above, of NULL, to be assignments of (HCRYPTPROV)NULL so that it builds without warnings regardless of what type HCRYPTPROV is defined to be. Should be a trivial fix. Thanks!

This was originally discussed in MesserLab/SLiM#66 but there's no need to read through that, it just says the same things I say above. :->

Metadata

Metadata

Labels

C APIIssue is about the C APIInfrastructure and toolsDevelopment infrastructure and tools

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions