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

Only use __attribute__((constructor)) if supported #66

Merged
merged 2 commits into from
Oct 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions include/dicom/dicom.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,6 @@
#define DCM_EXTERN __attribute__((visibility("default"))) extern
#endif

#ifdef HAS_CONSTRUCTOR
#define DCM_CONSTRUCTOR __attribute__ ((constructor))
#else
#define DCM_CONSTRUCTOR __attribute__ ((constructor))
#endif

/**
* Maximum number of characters in values with Value Representation AE.
*/
Expand Down Expand Up @@ -132,7 +126,6 @@ typedef struct _DcmSequence DcmSequence;
* This function can be called many times.
*/
DCM_EXTERN
DCM_CONSTRUCTOR
void dcm_init(void);

/* Our copy of getopt, since non-glibc platforms are missing this.
Expand Down
8 changes: 1 addition & 7 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,7 @@ if cc.has_header('unistd.h')
cfg.set('HAVE_UNISTD_H', '1')
endif
# we use a constructor attr for dcm_init()
code = '''#include<stdio.h>
__attribute__ ((constructor)) void func() { printf("constructor\n"); }
'''
cfg.set(
'HAS_CONSTRUCTOR',
cc.compiles(code, name : 'has constructor attribute')
)
cfg.set('HAS_CONSTRUCTOR', cc.has_function_attribute('constructor'))

configure_file(
output : 'config.h',
Expand Down
3 changes: 3 additions & 0 deletions src/dicom-dict.c
Original file line number Diff line number Diff line change
Expand Up @@ -5083,6 +5083,9 @@ static struct _DcmAttribute_hash_entry *attribute_from_tag_dict = NULL;
static struct _DcmAttribute_hash_entry *attribute_from_keyword_dict = NULL;


#ifdef HAS_CONSTRUCTOR
__attribute__ ((constructor))
#endif
void dcm_init(void)
{
if (!vrtable_from_str_dict) {
Expand Down