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

Fix compilation error for old version of GCC #48

Merged
merged 2 commits into from
Aug 31, 2022

Conversation

gleocadie
Copy link
Contributor

What does this PR do?

This PR fixes the C/C++ macro in the common.h file.

Motivation

This PR fixes the issue #47 for old GCC version.

How to test the change?

What I have done to validate the fix:

  • Followed the steps from [BUG] Cannot compile libdatadog common.h on gcc 4.9.2 #47 and checked that for this old version 4.9.2 the issue was fixed.
  • Compiled the .NET profiler on Linux with Clang 11.
  • Compiled a little C code which includes a modified version of common.h with a newer version of GCC (10.2.1)
  • Compiled the .NET profiler with a modified version of common.h (what you have in the fix)

@gleocadie gleocadie requested a review from a team as a code owner August 31, 2022 14:56
Copy link
Member

@ivoanjo ivoanjo left a comment

Choose a reason for hiding this comment

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

Left a tiny note, but overall it LGTM, thanks for looking into this!

@@ -22,12 +22,23 @@ after_includes = """
/* NOTE: Compilation fails if you pass in a char* instead of a literal */ ((ddog_CharSlice){ .ptr = "" string, .len = sizeof(string) - 1 })
#endif

#if defined __GNUC__
# define DDOG_GNUC_VERSION(major) __GNUC__ >= 4
Copy link
Member

Choose a reason for hiding this comment

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

major never gets used -- was the intention to use __GNUC__ >= major in the macro? 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oh yeah, good one. Will fix it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done in 114ba3c

Copy link
Contributor

@sanchda sanchda left a comment

Choose a reason for hiding this comment

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

Yup, attribute fences seems like a good fix--thank you!

# define DDOG_GNUC_VERSION(major) (0)
#endif

#if defined __has_attribute
Copy link
Contributor

Choose a reason for hiding this comment

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

Very reasonable--nice!

@gleocadie gleocadie merged commit 81b1753 into main Aug 31, 2022
@morrisonlevi morrisonlevi deleted the gleocadie/fix-common-h-for-gcc branch August 31, 2022 17:31
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.

3 participants