nemequ / hedley

A C/C++ header to help move #ifdefs out of your code
https://nemequ.github.io/hedley/
Creative Commons Zero v1.0 Universal
774 stars 51 forks source link

Incorporate MSVC's `__declspec(noalias)` #54

Open OfekShilon opened 2 years ago

OfekShilon commented 2 years ago

Microsoft's __declspec(noalias) is documented as:

noalias means that a function call doesn't modify or reference visible global state and only modifies the memory pointed to directly by pointer parameters (first-level indirections).

So it is analogous to gcc/clang __attribute__((const)). Currently HEDLEY_CONST does not generate it.

apache-hb commented 6 months ago

According to the gcc docs. const functions should never take pointer or, in C++, reference arguments.

This seems to conflict with msdn noalias docs noalias means that a function call doesn't modify or reference visible global state and only modifies the memory pointed to directly by pointer parameters (first-level indirections).

These appear to be incompatible, im not sure HEDLEY_CONST would be a correct place for __declspec(noalias)