Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correct behavior for functions implemented in header files #243

Open
andre2007 opened this issue Feb 19, 2020 · 1 comment
Open

Correct behavior for functions implemented in header files #243

andre2007 opened this issue Feb 19, 2020 · 1 comment
Labels
bug workaround A workaround exists

Comments

@andre2007
Copy link

See here for an example

https://github.com/Azure/azure-sdk-for-c/blob/master/sdk/core/core/inc/az_span.h#L91

AZ_NODISCARD AZ_INLINE az_span az_span_init(uint8_t * ptr, int32_t length, int32_t capacity) {
  return (az_span){ ._internal = { .ptr = ptr, .length = length, .capacity = capacity, }, };
}

As it is an inline function and defined and implemented in the header file, it wont be in the fields symbols of the resulting static/dynamic library. Therefore linker will always fail.
It has to be implemented in D coding (in the DPP module like for macros)

I wonder what is the correct behavior for Dpp. At the moment the signature is added in the generated module, with extern(C) declaration.

@atilaneves
Copy link
Owner

There's a workaround which is to make the C compiler emit code for this in a C translation unit and link to that. Translating arbitrary C code is going to take a lot of work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug workaround A workaround exists
Projects
None yet
Development

No branches or pull requests

2 participants