azure-sdk-for-c: Functions implemented in header files causes issues

Describe the bug

Functions implemented in header files, like az_span_init: https://github.com/Azure/azure-sdk-for-c/blob/master/sdk/core/core/inc/az_span.h#L91 will not be accessible in the target static libraries. Therefore this library cannot be used from other programming languages like D.

To Reproduce On linux execute command:

nm ./libaz_core.a

Expected behavior Please move the functions implementations from the *.h files to the *.c files. Various header files are affected.

Screenshots

nm ./libaz_core.a
...
az_span.c.o:
                 U _GLOBAL_OFFSET_TABLE_
                 U __ctype_b_loc
                 U __stack_chk_fail
00000000000025cb T _az_is_expected_span
0000000000002802 T _az_scan_until
00000000000014d5 T _az_span_append_zeros
000000000000229c t _az_span_builder_append_uint64
0000000000001850 T _az_span_replace
0000000000000f69 T _az_span_swap
00000000000011b6 T az_span_append
0000000000001ed7 T az_span_append_double
000000000000250a T az_span_append_int64
00000000000024d7 T az_span_append_uint64
00000000000005cb T az_span_copy
0000000000000983 T az_span_copy_url_encode
00000000000003a7 T az_span_is_content_equal_ignoring_case
0000000000000000 T az_span_slice
0000000000001055 T az_span_to_str
00000000000004ac T az_span_to_uint64
                 U memcmp
                 U memmove
                 U memset

az_span_init is missing here because it is implemented in the header file.

Setup (please complete the following information):

  • OS: Ubuntu
  • IDE :
  • Version: master

Information Checklist Kindly make sure that you have added all the following information above and checkoff the required fields otherwise we will treat the issuer as an incomplete report

  • Bug Description Added
  • Repro Steps Added
  • Setup information Added

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 16 (8 by maintainers)

Most upvoted comments

@ahsonkhan The workaround is to copy the coding from the inlined functions defined in the header files and port it to the target language. Example for az_span_init and D

az_span az_span_init(uint8_t* ptr, int32_t length, int32_t capacity)
{
    az_span result = {{ptr: ptr, length: length, capacity: capacity}};
    return result;
}

I just noticed, az_span_init was renamed in the meantime to az_span_create and a non inlined function is provided too. It seems there was already some work started to solve the problem of the inlined functions.