473,779 Members | 1,921 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

C Library Wrapper in C++

Ian
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****@yahoo.co m
Jul 19 '05 #1
3 10245
On 16 Oct 2003 14:12:08 -0700, mc****@yahoo.co m (Ian) wrote in
comp.lang.c++:
Has anyone had any experience in writing wrappers for older C
libraries?
Yes, many people have.
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,


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
Jul 19 '05 #2
Jack Klein <ja*******@spam cop.net> wrote in message news:<cl******* *************** **********@4ax. com>...
On 16 Oct 2003 14:12:08 -0700, mc****@yahoo.co m (Ian) wrote in
comp.lang.c++:
Has anyone had any experience in writing wrappers for older C
libraries?


Yes, many people have.
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,


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.


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.
Jul 19 '05 #3
Alan Gifford wrote:
Jack Klein <ja*******@spam cop.net> wrote in message news:<cl******* *************** **********@4ax. com>...
On 16 Oct 2003 14:12:08 -0700, mc****@yahoo.co m (Ian) wrote in
comp.lang.c++ :

Has anyone had any experience in writing wrappers for older C
libraries?


Yes, many people have.

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,


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.



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.


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.

Jul 19 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2289
by: Mark McEahern | last post by:
I just wrote a very simple wrapper for the PayFlow Pro SDK (see below). A friend of mine did this before, but I didn't have access to his source, so I took it as a learning opportunity for me to write a C wrapper. I did a little searching to see whether anyone had done anything like this for Python. I didn't find anything. I did find that PHP comes with an extension for PayFlow Pro that you can compile into the language:
1
1829
by: Yaniv Oliver | last post by:
Hey, I'm currently writing a C# wrapper for a library that was originally written in C. The wrapper is basiclly working, but I'm having trouble writing a wrapper for this kind of code segment: typedef int (*callback_function)(char *string); __declspec(dllimport) BOOL DLL(some_function)(callback_function some_ther_function);
0
2483
by: Claire | last post by:
Hi Ive been using Mattias Sjögren's example at http://www.msjogren.net/dotnet/eng/samples/dotnet_dynpinvoke.asp to load an unmanaged 3rd party dll dynamically when my object is created. Calling the "CreateDllAssembly" function below does this. When my wrapper is disposed of, I want the dll to be unloaded from memory. See the "dispose" function below. All seems to work ok on the first instance of my wrapper class. (I only
1
1717
by: Steve Terepin | last post by:
I've found some rather worrying articles (Mixed Mode Library Assembly bug, Richard Grimes, Windows Developer Network Sept 2003 ; and Knowledge Base Article 814472 ) that point out the need to use the /noentry switch and an explicit initialisation procedure, to be able to safely use Managed C++ assemblies that call down into standard C library functions. Could someone confirm that I've understood this properly ? I'm writing some Managed...
1
7161
by: Adam Clauss | last post by:
I have an unmanaged C++ library that I need to use through C#. I created a Managed C++ class library and through it wrote a wrapper class to call what I need. However, one of the methods (an Initialize function in the unmanaged library) crashes everytime I call it. Initialize calls another function 'GetInstance' (a static member function of a class) which looks something like: CLibConfig& CLibConfig::GetInstance()
5
2163
by: Octal | last post by:
How does the lambda library actually works. How does it know how to evaluate _1, how does it recognize _1 as a placeholder, how does it then calculate _1+_2, or _1+2 etc. The source files seem a bit complicated so any explanation would be appreciated. Thanks
1
2367
by: dfj225 | last post by:
While my question doesn't pertain specifically to python programming, it is a result of developing a python module, so I'm hoping someone here might have experience with this issue. So, first a little background to how the system works right now. I am developing a module for Python. The original code is written in C++ and I am creating a wrapper using Boost.Python. The C++ code for the module makes calls into a library that in turn...
3
2959
by: jonlynch71 | last post by:
Hi, I have a statically-linked C library (.lib) that I need to be able to access from C#. I understand that the best way to do this is to code a C++ managed wrapper. How do I create this wrapper? One of the functions in this library is as follows: int *func2 (int *ary, int n, char *str)
2
5719
by: Serman D. | last post by:
Hi all, I'm trying to complete the samples from the excellent 2003 developerWorks article "Bringing the Power of Regular Expression Matching to SQL" by Knut Stolze: http://tinyurl.com/3bhrnn I've managed to compile and link the C code from "Listing 5", the regexpSimple() wrapper (see link). The build options are pretty much
1
1672
by: £ukasz Z±bik | last post by:
I have project that uses managed c++ where I use c - library, this library contains some variables named generic, during compilation I get error: Error 1 error C2146: syntax error : missing ';' before identifier 'generic', Problem is that in dotNet generic is a keyword, and I cannot change this name becouse I have only lib file and includes. How to solve this problem? -- pozdrawiam £ukasz
0
9632
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10302
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9925
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7478
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6723
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5372
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4036
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3631
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2867
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.