Commit aedc4ed0 authored by Marijn Kruisselbrink's avatar Marijn Kruisselbrink Committed by Commit Bot

Non-string constants in structs and interfaces need a definition too.

Without this ODR-using these constants will cause linking errors.
Namespace scoped constants are fine without a definition, since those
have internal linkage and thus every user gets their own copy of the
constant anyway.

Bug: 
Change-Id: I361fc705500d67f010498208622022e81a20b2eb
Reviewed-on: https://chromium-review.googlesource.com/521767Reviewed-by: default avatarYuzhu Shen <yzshen@chromium.org>
Commit-Queue: Marijn Kruisselbrink <mek@chromium.org>
Cr-Commit-Position: refs/heads/master@{#476534}
parent f60316be
......@@ -50,6 +50,8 @@ const char {{class_name}}::Name_[] = "{{namespace_as_string}}::{{class_name}}";
{%- for constant in interface.constants %}
{%- if constant.kind|is_string_kind %}
const char {{interface.name}}::{{constant.name}}[] = {{constant|constant_value}};
{%- else %}
constexpr {{constant.kind|cpp_pod_type}} {{interface.name}}::{{constant.name}};
{%- endif %}
{%- endfor %}
......
......@@ -59,6 +59,8 @@ const char {{constant.name}}[] = {{constant|constant_value}};
{%- for constant in struct.constants %}
{%- if constant.kind|is_string_kind %}
const char {{struct.name}}::{{constant.name}}[] = {{constant|constant_value}};
{%- else %}
constexpr {{constant.kind|cpp_pod_type}} {{struct.name}}::{{constant.name}};
{%- endif %}
{%- endfor %}
{%- endfor %}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment