Skip to content

Fix C API for Visual Studio#184

Merged
hobu merged 1 commit intolibspatialindex:masterfrom
SpaceIm:fix-capi-for-msvc
Apr 24, 2020
Merged

Fix C API for Visual Studio#184
hobu merged 1 commit intolibspatialindex:masterfrom
SpaceIm:fix-capi-for-msvc

Conversation

@SpaceIm
Copy link
Copy Markdown
Contributor

@SpaceIm SpaceIm commented Mar 27, 2020

closes #179

cinttypes was included, but it's a C++ header.
Instead, stdint.h is included for Visual Studio 2010+
@hobu
Copy link
Copy Markdown
Member

hobu commented Mar 28, 2020

Can you provide more detail why this change was needed?

#if _MSC_VER >= 1900
#include <cinttypes>
#else
#include <stdint.h>
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use cstdint instead.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cstdint is a C++ header. Why do you want to include a C++ header in a C API?

@SpaceIm
Copy link
Copy Markdown
Contributor Author

SpaceIm commented Mar 28, 2020

Because cinttypes is a C++ header, therefore a pure C program will fail to compile with msvc.

C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.25.28610\include\cstdint(21,1): error C2061: syntax error : identifier 'std'

And this is also why cstdint must not be included in a C API.

@hobu hobu closed this Apr 24, 2020
@hobu hobu reopened this Apr 24, 2020
@hobu hobu merged commit 2f79e35 into libspatialindex:master Apr 24, 2020
@hobu hobu added this to the 2.0.0 milestone Apr 24, 2020
@SpaceIm SpaceIm deleted the fix-capi-for-msvc branch April 24, 2020 17:39
@hobu hobu modified the milestones: 2.0.0, 2.1.0 Nov 20, 2024
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.

C API: do not include cinttypes for MSVC 2015+

3 participants