<blockquote>
<p><a class="user-mention" data-hovercard-type="user" data-hovercard-url="/hovercards?user_id=793526" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/b4n">@b4n</a> for the places this is used, is there a (compile time testable) value of array element you could use as a non-entry so its always arrays and so doesn't mix arrays and pointers, then the GCC warning will catch if anyone does call it with a pointer?</p>
</blockquote>
<p>None that I can think of; the non-array values are <code>EMPTY_KEYWORDS</code> and <code>EMPTY_PROPERTIES</code>.  If ISO C allowed it, the simple fix would be to declare those as empty arrays, and it would naturally work out of the box.  But without this, the best other solution I can think of is this:</p>
<div class="highlight highlight-source-diff"><pre><span class="pl-c1">diff --git a/src/highlighting.c b/src/highlighting.c</span>
index 938e5432c..82013aa7c 100644
<span class="pl-md">--- a/src/highlighting.c</span>
<span class="pl-mi1">+++ b/src/highlighting.c</span>
<span class="pl-mdr">@@ -961,9 +961,9 @@</span> static guint get_lexer_filetype(GeanyFiletype *ft)
        case (GEANY_FILETYPES_##LANG_NAME): \
                styleset_init_from_mapping(filetype_idx, config, configh, \
                                highlighting_styles_##LANG_NAME, \
<span class="pl-md"><span class="pl-md">-</span>                          HL_N_ENTRIES(highlighting_styles_##LANG_NAME), \</span>
<span class="pl-mi1"><span class="pl-mi1">+</span>                                HL_N_STYLES(highlighting_styles_##LANG_NAME), \</span>
                                highlighting_keywords_##LANG_NAME, \
<span class="pl-md"><span class="pl-md">-</span>                          HL_N_ENTRIES(highlighting_keywords_##LANG_NAME)); \</span>
<span class="pl-mi1"><span class="pl-mi1">+</span>                                HL_N_KEYWORDS(highlighting_keywords_##LANG_NAME)); \</span>
                break
 
 /* Called by filetypes_load_config(). */
<span class="pl-mdr">@@ -1068,11 +1068,11 @@</span> void highlighting_init_styles(guint filetype_idx, GKeyFile *config, GKeyFile *co
        case (GEANY_FILETYPES_##LANG_NAME): \
                styleset_from_mapping(sci, ft->id, highlighting_lexer_##LANG_NAME, \
                                highlighting_styles_##LANG_NAME, \
<span class="pl-md"><span class="pl-md">-</span>                          HL_N_ENTRIES(highlighting_styles_##LANG_NAME), \</span>
<span class="pl-mi1"><span class="pl-mi1">+</span>                                HL_N_STYLES(highlighting_styles_##LANG_NAME), \</span>
                                highlighting_keywords_##LANG_NAME, \
<span class="pl-md"><span class="pl-md">-</span>                          HL_N_ENTRIES(highlighting_keywords_##LANG_NAME), \</span>
<span class="pl-mi1"><span class="pl-mi1">+</span>                                HL_N_KEYWORDS(highlighting_keywords_##LANG_NAME), \</span>
                                highlighting_properties_##LANG_NAME, \
<span class="pl-md"><span class="pl-md">-</span>                          HL_N_ENTRIES(highlighting_properties_##LANG_NAME)); \</span>
<span class="pl-mi1"><span class="pl-mi1">+</span>                                HL_N_PROPERTIES(highlighting_properties_##LANG_NAME)); \</span>
                break
 
 /** Sets up highlighting and other visual settings.
<span class="pl-c1">diff --git a/src/highlightingmappings.h b/src/highlightingmappings.h</span>
index d62b7e24b..36fe2d260 100644
<span class="pl-md">--- a/src/highlightingmappings.h</span>
<span class="pl-mi1">+++ b/src/highlightingmappings.h</span>
<span class="pl-mdr">@@ -65,11 +65,14 @@</span> typedef struct
 } HLProperty;
 
 
<span class="pl-md"><span class="pl-md">-</span>#define EMPTY_KEYWORDS            ((HLKeyword *) NULL)</span>
<span class="pl-md"><span class="pl-md">-</span>#define EMPTY_PROPERTIES  ((HLProperty *) NULL)</span>
<span class="pl-md"><span class="pl-md">-</span></span>
<span class="pl-md"><span class="pl-md">-</span>/* like G_N_ELEMENTS() but supports @array being NULL (for empty entries) */</span>
<span class="pl-md"><span class="pl-md">-</span>#define HL_N_ENTRIES(array) ((array != NULL) ? G_N_ELEMENTS(array) : 0)</span>
<span class="pl-mi1"><span class="pl-mi1">+</span>/* ISO C doesn't allow zero-sized arrays, so we special-case those below */</span>
<span class="pl-mi1"><span class="pl-mi1">+</span>static const HLKeyword EMPTY_KEYWORDS[] = {{0}};</span>
<span class="pl-mi1"><span class="pl-mi1">+</span>static const HLProperty EMPTY_PROPERTIES[] = {{0}};</span>
<span class="pl-mi1"><span class="pl-mi1">+</span></span>
<span class="pl-mi1"><span class="pl-mi1">+</span>/* like G_N_ELEMENTS() but supports special values for empty entries */</span>
<span class="pl-mi1"><span class="pl-mi1">+</span>#define HL_N_STYLES(ss) G_N_ELEMENTS(ss)</span>
<span class="pl-mi1"><span class="pl-mi1">+</span>#define HL_N_KEYWORDS(ks) ((ks) == EMPTY_KEYWORDS ? 0 : G_N_ELEMENTS(ks))</span>
<span class="pl-mi1"><span class="pl-mi1">+</span>#define HL_N_PROPERTIES(ps) ((ps) == EMPTY_PROPERTIES ? 0 : G_N_ELEMENTS(ps))</span>
 
 
 /* Abaqus */</pre></div>
<p>but I'm not really convinced it's actually better.  I'm not against it, it's not really bad but it's kind of sad it wastes <code>sizeof(HLKeyword) + sizeof(HLProperty)</code> (40 bytes here) and introduces 2 new specific macros.</p>
<p>As for getting called with a pointer it's a theoretically good point, but given it's only used on highlightingmappings entries, it should be fairly safe.</p>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />You are receiving this because you are subscribed to this thread.<br />Reply to this email directly, <a href="https://github.com/geany/geany/pull/2398?email_source=notifications&email_token=AAIOWJ2UO6I2CNGQYIAECW3QUFLNTA5CNFSM4JOGEJQKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEEINZPA#issuecomment-554753212">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/AAIOWJZK24Q2CPTZISHURDDQUFLNTANCNFSM4JOGEJQA">unsubscribe</a>.<img src="https://github.com/notifications/beacon/AAIOWJZE5NWPJJFQLYQP7Z3QUFLNTA5CNFSM4JOGEJQKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEEINZPA.gif" height="1" width="1" alt="" /></p>
<script type="application/ld+json">[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/geany/geany/pull/2398?email_source=notifications\u0026email_token=AAIOWJ2UO6I2CNGQYIAECW3QUFLNTA5CNFSM4JOGEJQKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEEINZPA#issuecomment-554753212",
"url": "https://github.com/geany/geany/pull/2398?email_source=notifications\u0026email_token=AAIOWJ2UO6I2CNGQYIAECW3QUFLNTA5CNFSM4JOGEJQKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEEINZPA#issuecomment-554753212",
"name": "View Pull Request"
},
"description": "View this Pull Request on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]</script>