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

C file should not include <cinttypes>, it is a C++ header. #5499

Closed
wants to merge 1 commit into from

Conversation

spetrunia
Copy link
Contributor

Include <inttypes.h> instead.

@spetrunia
Copy link
Contributor Author

spetrunia commented Jun 22, 2019

Background:
The issue is caused by a recent patch in RocksDB:
d68f9f4
the patch did a bulk change:

-#include <inttypes.h>
+#include <cinttypes>

and accidentally changed a C file. The patch also removed #define __STDC_FORMAT_MACROS . crc32c_ppc.c does not use format macros, so I'm not putting that #define back.

As a consequence, MyRocks/MariaDB build fails on PPC now: https://jira.mariadb.org/browse/MDEV-19830

Copy link
Contributor

@miasantreble miasantreble left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for the fix

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

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

@miasantreble has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@riversand963
Copy link
Contributor

Do we need the __STDC_FORMAT_MACROS?

@siying
Copy link
Contributor

siying commented Jun 24, 2019

@riversand963 if it compiles, then we don't need it.

@miasantreble
Copy link
Contributor

miasantreble commented Jun 24, 2019

@spetrunia if this file doesn't use format macros then maybe we can simply remove the include?

@riversand963
Copy link
Contributor

@riversand963 if it compiles, then we don't need it.

According to people's experience with different compilers, e.g. https://stackoverflow.com/questions/14535556/why-doesnt-priu64-work-in-this-code, if #include <inttypes.h> is present, we should always use __STDC_FORMAT_MACROS.

@siying
Copy link
Contributor

siying commented Jun 24, 2019

@riversand963 I wonder whether __STDC_FORMAT_MACROS is a C++ thing or also is also applied to C. If it is a C++ thing, then we should not have it at all. The macro has name STD on it, so I suspect that it is a C++ thing.

@riversand963
Copy link
Contributor

@siying , SG. Should not be necessary for C.

@spetrunia
Copy link
Contributor Author

spetrunia commented Jun 24, 2019

@spetrunia if this file doesn't use format macros then maybe we can simply remove the include?

Actually, seems like yes. I don't have access to a power8 machine, but examining the file manually, it looks like the #include <stdint.h> could be removed.

EDIT: Wait, crc32c_ppc.c uses uint32_t, which is according to https://pubs.opengroup.org/onlinepubs/009695399/basedefs/stdint.h.html or https://en.cppreference.com/w/c/types/integer is defined in stdint.h . inttypes.h can also be used as it includes that file: http://pubs.opengroup.org/onlinepubs/009696799/basedefs/inttypes.h.html

Should this be done in the scope of this PR or the current variant is fine too?

@miasantreble
Copy link
Contributor

Should this be done in the scope of this PR or the current variant is fine too?

I'd prefer removing unnecessary include directives

@spetrunia
Copy link
Contributor Author

@miasantreble, changed the patch to include stdint.h. Please review

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

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

@miasantreble has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link
Contributor

@miasantreble merged this pull request in e731f44.

@adamretter
Copy link
Collaborator

@siying @gfosco this one is needed in 6.3 branch to be able to do releases for PPC, could you also check that it goes into newer branches too? For now I have manually picked it onto v6.3.6 to be able to build the release.

merryChris pushed a commit to merryChris/rocksdb that referenced this pull request Nov 18, 2019
…5499)

Summary:
Include <inttypes.h> instead.
Pull Request resolved: facebook#5499

Differential Revision: D15966937

Pulled By: miasantreble

fbshipit-source-id: 2156c4329b91d26d447de94f1231264d52786350
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants