C Library Wrapper in C++

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Ian

    C Library Wrapper in C++

    Has anyone had any experience in writing wrappers for older C
    libraries?
    What I'm looking at doing is creating a wrapper C++ object as a front
    end to an older C library, also the library is not thread-safe, which
    I have to somehow make safe for multi-threading (CRITICAL_SECTI ONS
    maybe) for integration into a server.

    Thanks,

    Ian
    mc_ian@yahoo.co m
  • Jack Klein

    #2
    Re: C Library Wrapper in C++

    On 16 Oct 2003 14:12:08 -0700, mc_ian@yahoo.co m (Ian) wrote in
    comp.lang.c++:
    [color=blue]
    > Has anyone had any experience in writing wrappers for older C
    > libraries?[/color]

    Yes, many people have.
    [color=blue]
    > What I'm looking at doing is creating a wrapper C++ object as a front
    > end to an older C library, also the library is not thread-safe, which
    > I have to somehow make safe for multi-threading (CRITICAL_SECTI ONS
    > maybe) for integration into a server.
    >
    > Thanks,[/color]

    The C++ language does not define or support multiple threads of
    execution, so that aspect of your question is off-topic here. You
    need to ask in a Windows programming group.

    --
    Jack Klein
    Home: http://JK-Technology.Com
    FAQs for
    comp.lang.c http://www.eskimo.com/~scs/C-faq/top.html
    comp.lang.c++ http://www.parashift.com/c++-faq-lite/
    alt.comp.lang.l earn.c-c++ ftp://snurse-l.org/pub/acllc-c++/faq

    Comment

    • Alan Gifford

      #3
      Re: C Library Wrapper in C++

      Jack Klein <jackklein@spam cop.net> wrote in message news:<clluovsvd 45us1bl7eh2qict bcbndqilul@4ax. com>...[color=blue]
      > On 16 Oct 2003 14:12:08 -0700, mc_ian@yahoo.co m (Ian) wrote in
      > comp.lang.c++:
      >[color=green]
      > > Has anyone had any experience in writing wrappers for older C
      > > libraries?[/color]
      >
      > Yes, many people have.
      >[color=green]
      > > What I'm looking at doing is creating a wrapper C++ object as a front
      > > end to an older C library, also the library is not thread-safe, which
      > > I have to somehow make safe for multi-threading (CRITICAL_SECTI ONS
      > > maybe) for integration into a server.
      > >
      > > Thanks,[/color]
      >
      > The C++ language does not define or support multiple threads of
      > execution, so that aspect of your question is off-topic here. You
      > need to ask in a Windows programming group.[/color]



      So you mean you can't use multithreading with C++ programs in Linux?
      A co-worker was telling me about using C++ classes to handle locks and
      some other stuff in multithreading (I don't know how to do it yet)
      that made it really easy, but I think he was talking about Windows NT
      programming.

      Comment

      • red floyd

        #4
        Re: C Library Wrapper in C++

        Alan Gifford wrote:[color=blue]
        > Jack Klein <jackklein@spam cop.net> wrote in message news:<clluovsvd 45us1bl7eh2qict bcbndqilul@4ax. com>...
        >[color=green]
        >>On 16 Oct 2003 14:12:08 -0700, mc_ian@yahoo.co m (Ian) wrote in
        >>comp.lang.c++ :
        >>
        >>[color=darkred]
        >>>Has anyone had any experience in writing wrappers for older C
        >>>libraries?[/color]
        >>
        >>Yes, many people have.
        >>
        >>[color=darkred]
        >>>What I'm looking at doing is creating a wrapper C++ object as a front
        >>>end to an older C library, also the library is not thread-safe, which
        >>>I have to somehow make safe for multi-threading (CRITICAL_SECTI ONS
        >>>maybe) for integration into a server.
        >>>
        >>>Thanks,[/color]
        >>
        >>The C++ language does not define or support multiple threads of
        >>execution, so that aspect of your question is off-topic here. You
        >>need to ask in a Windows programming group.[/color]
        >
        >
        >
        >
        > So you mean you can't use multithreading with C++ programs in Linux?
        > A co-worker was telling me about using C++ classes to handle locks and
        > some other stuff in multithreading (I don't know how to do it yet)
        > that made it really easy, but I think he was talking about Windows NT
        > programming.[/color]

        No, he means that it's not built into the Standard C++ language.
        Wrappers and such for multithreading APIs are OS and/or MT
        implementation specific, and are not discussed in the standard.

        That said, I have several classes that wrap up some Win32 multithreading
        primitives. They are implemented in Standard C++, but they are not part
        of Standard C++.

        C++ is a great language for this sort of wrapper, because it helps to
        avoid problems such as mutexes and critical sections accidentally left
        locked. But because they're OS specific, they're not in the standard.

        Comment

        Working...