Skip to content

Conversation

@droberts195
Copy link

@droberts195 droberts195 commented May 23, 2018

  1. There's no need for constants declared in unnamed namespaces
    to be declared static - they already have internal linkage.
  2. Constants of type char* pointing to literals should be
    declared const char* const - declaring them const char* does
    not result in internal linkage because it allows them to be
    changed to point at something completely different!

1. There's no need for constants declared in unnamed namespaces
   to be declared static - they already have internal linkage
2. Constants of type char* pointing to literals should be
   declared const char* const - declaring them const char* does
   not result in internal linkage because it allows them to be
   changed to point at something completely different!
Copy link
Member

@davidkyle davidkyle left a comment

Choose a reason for hiding this comment

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

LGTM. left a question

#else
#ifdef __GNUC__
// Tell g++ that it's reasonable that this variable isn't used
__attribute__((unused)) static const char* LINE_ENDING = "\n";
Copy link
Member

Choose a reason for hiding this comment

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

Not needed?

Copy link
Author

@droberts195 droberts195 May 23, 2018

Choose a reason for hiding this comment

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

No, now this really is a constant with internal linkage it's not needed.

In fact, the warning from g++ was the canary in the mine warning that something was not right. Suppressing the warning was the wrong way to avoid it.

@droberts195 droberts195 merged commit 18381b9 into elastic:master May 24, 2018
@droberts195 droberts195 deleted the correct_const_internal_linkage branch May 24, 2018 08:27
droberts195 pushed a commit that referenced this pull request May 24, 2018
1. There's no need for constants declared in unnamed namespaces
   to be declared static - they already have internal linkage.
2. Constants of type char* pointing to literals should be
   declared const char* const - declaring them const char* does
   not result in internal linkage because it allows them to be
   changed to point at something completely different!
@sophiec20 sophiec20 added :ml and removed :ml labels Jun 12, 2018
droberts195 pushed a commit to droberts195/ml-cpp that referenced this pull request Feb 21, 2019
Follow-on to elastic#102.  Fixing more places where pointers intended
to be immutable could be changed to a point at a different
constant.
droberts195 pushed a commit that referenced this pull request Feb 21, 2019
Follow-on to #102.  Fixing more places where pointers intended
to be immutable could be changed to a point at a different
constant.
droberts195 pushed a commit to droberts195/ml-cpp that referenced this pull request Feb 21, 2019
Follow-on to elastic#102.  Fixing more places where pointers intended
to be immutable could be changed to a point at a different
constant.

Backport of elastic#409
droberts195 pushed a commit that referenced this pull request Feb 22, 2019
Follow-on to #102.  Fixing more places where pointers intended
to be immutable could be changed to a point at a different
constant.

Backport of #409
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.

3 participants