Using extern C for some C-compatible methods

All other questions regarding DCMTK

Moderator: Moderator Team

Post Reply
Message
Author
theonlylawislove
Posts: 34
Joined: Thu, 2014-07-17, 09:07

Using extern C for some C-compatible methods

#1 Post by theonlylawislove »

I am working on an interop library so that dcmtk may be used in managed languages (C#, etc).

With that said, I initially looked at wrapper scp.h, and a few others, but it seems that all these higher-level C++ classes just wrap lower-level C-like methods.

http://git.dcmtk.org/?p=dcmtk.git;a=blo ... .h;hb=HEAD

I'd like to wrap these methods and invoke that from managed languages, however, you aren't using extern C for the dul.h (and others) headers.

This makes the C functions exported with mangled names.

00000000008454b0 T _Z15ASC_getAPTitlesP16T_ASC_ParametersPcS1_S1_

I can't properly invoke these methods from managed languages without extern C, due to the fragile nature of mangled names across environments and compilers.

What do you guys think about wrapping them up with an extern C for use in C projects?

I'd like to use these C functions, and create managed (C#/Java) wrapper classes for SCU/SCP stuff.

It looks like part of the DCMTK API was intended to be targeted for C. char* is used, instead of OFString, etc. Why not extern C?

J. Riesmeier
DCMTK Developer
Posts: 2501
Joined: Tue, 2011-05-03, 14:38
Location: Oldenburg, Germany
Contact:

Re: Using extern C for some C-compatible methods

#2 Post by J. Riesmeier »

For historical reasons, the core functions of the "dcmnet" module still use a C-based API. This is the oldest part within the DCMTK. Development started back in 1993 when the first two reference implementations were developed... However, also the core functions nowadays use C++ classes, e.g. OFCondition for the returned status, DcmFileFormat and DcmDataset for the DICOM dataset, etc.

The "new" wrapper classes like DcmSCU and DcmSCP are intended to hide these ancient C-like functions and data structures from the user. So, I personally, would use the C++ classes rather than the C-like functions and data structures. We know that the C++ wrappers are not yet complete but we extend them step-by-step as needed (e.g. for our own purposes).

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot], Google [Bot] and 1 guest