Skip to content

Conversation

@Przemog1
Copy link
Contributor

@Przemog1 Przemog1 commented Jan 8, 2026

No description provided.

for (const auto& define : preprocessOptions.extraDefines)
context.add_macro_definition(define.identifier.data() + core::string("=") + define.definition.data());
{
const std::string macroDefinition = define.identifier.data() + core::string("=") + define.definition.data();

Choose a reason for hiding this comment

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

do we suppose define.definition being a null span ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

define.definition can be an empty string but not a null span

macroDefinitions.emplace_back(macroDefinitionBuffer.identifier, macroDefinitionBuffer.definition);
}

opt.preprocessorOptions.extraDefines = macroDefinitions;
Copy link
Member

Choose a reason for hiding this comment

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

ok but you forgot about preprocessOnly mode

{
const std::string macroDefinition = define.identifier.data() + core::string("=") + define.definition.data();
const bool isMacroAdded = context.add_macro_definition(macroDefinition);
assert(isMacroAdded);
Copy link
Member

@AnastaZIuk AnastaZIuk Jan 21, 2026

Choose a reason for hiding this comment

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

a duplicate should not be asserted, in this case silent fail is better

you actually better just move .add_macro_definition into try block to let wave throw an exception which we handle nicely than assert (then we come back to silent fail + opportunity to catch stuff)

Comment on lines +523 to +527
const size_t equalPos = argumentTmp.find('=');
if (equalPos == std::string::npos)
{
identifier = argumentTmp;
definition = "";
Copy link
Member

Choose a reason for hiding this comment

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

it changes semantic of -D compared to how DXC/Clang/GCC and friends handle it

lack of = means empty definition now, try adding -DNAME and then

  1. #if NAME
  2. #if NAME == 1
  3. #if defined(NAME) && NAME
  4. #if NAME >= 2
  5. int x = NAME;

on -DNAME we should be defining 1 (-DNAME == -DNAME=1) in this case otherwise those above will fail

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.

4 participants