#Invalid macro invocation + other errors

39 messages · Page 1 of 1 (latest)

worthy boughBOT
#

When your question is answered use !solved to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.

wet fulcrum
#

@dawn solar you declare c bool NAME##_get_entry(const NAME *, K, NAME##_entry_t **); and then define ```c
bool NAME##_get_entry(NAME *__hashmap, K key, NAME##_entry_t **found_entry) {

#

hmmmm

#

__hashmap is a reserved identifier >:(

#

||consider doing something like LIBRARYNAME_DETAIL_VAR_HASHMAP||

regal verge
wet fulcrum
#

preprocessed?

regal verge
#

yes

wet fulcrum
#

how did you avoid preprocessing the includes

regal verge
#

i just removed them

wet fulcrum
#

did you just take them out and put them back in after prepreocessing the rest

#

ah

regal verge
#

it was that easy

regal verge
wet fulcrum
#

i think hashmap_new and hashmap_delete make more sense, to be consistent with everything else

regal verge
#

it's not consistently doing it for everything to avoid issues with macros

wet fulcrum
#

makes it more consistent

#

technically

#

hashmap_construct, hashmap_destruct

regal verge
#

yes

#

All identifiers that begin with an underscore and either an uppercase letter or another underscore are always reserved for any use, except those identifiers which are lexically identical to keywords.
Section 7.1.3 "Reserved identifiers" Paragraph 1 C17

#

@dawn solar

regal verge
wet fulcrum
#

eh

regal verge
#

destructor was probably just chosen because destroyer would sound awkward

wet fulcrum
#

reserved identifiers

#

what did you do instead?

#

this can be ```c
if (has_entry) {
found_entry->val = new_val;
}
return false;

regal verge
#

why the null checks

#

you don't have to do a null check for every input parameter, just document it as a precondition

wet fulcrum
#

"passing null is UB"

#

ez

#

huh

#

glad i caught it i guess

regal verge
#

the main one is seems weird with is destroy_hashmap

#

because it seems like that return value would be used for if something during destruction actually went wrong

#

like how fclose can fail for example, but it's really just a sanity check and the return value indicates if you were insane or not