473,324 Members | 2,548 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

How to include header file used by DLL

Dv
I have a API lib (written in C/C++) that can be used by C/C++ project.
Now, I'm adding support to C# project.

I changed the Lib to DLL. This is easy. However, I have no idea how to
deal with the structures and constants that used to be defined in the
header file of the lib.

Where should I define them that they can be commonly used by the DLL, C
++ and C#, and also is readable to their developers from their IDEs?

Thanks!
-Dev

Mar 16 '07 #1
3 7889
On Mar 16, 9:09 am, "Dv" <dev...@gmail.comwrote:
I have a API lib (written in C/C++) that can be used by C/C++ project.
Now, I'm adding support to C# project.

I changed the Lib to DLL. This is easy. However, I have no idea how to
deal with the structures and constants that used to be defined in the
header file of the lib.

Where should I define them that they can be commonly used by the DLL, C
++ and C#, and also is readable to their developers from their IDEs?

Thanks!
-Dev

I think I understand the question. By default, the C# engine will know
how to comile your existing function calls, constants, etc based on
the DLL.

However, if you want those constants to pop up in the intellisense
menus, then you may be pushing your luck. It won't auto-load them into
Intellisense for you.

Instead, you may want to create new declarations in C# as constants
that mimic your C++ constants. The problem is that now you have two
sets of "constants" to maintain.

Hope that helps.

--Sim

Mar 16 '07 #2
Dv
On Mar 16, 10:32 am, "SimeonArgus" <simeontr...@gmail.comwrote:
On Mar 16, 9:09 am, "Dv" <dev...@gmail.comwrote:
I have a API lib (written in C/C++) that can be used by C/C++ project.
Now, I'm adding support to C# project.
I changed the Lib to DLL. This is easy. However, I have no idea how to
deal with the structures and constants that used to be defined in the
header file of the lib.
Where should I define them that they can be commonly used by the DLL, C
++ and C#, and also is readable to their developers from their IDEs?
Thanks!
-Dev

I think I understand the question. By default, the C# engine will know
how to comile your existing function calls, constants, etc based on
the DLL.

However, if you want those constants to pop up in the intellisense
menus, then you may be pushing your luck. It won't auto-load them into
Intellisense for you.

Instead, you may want to create new declarations in C# as constants
that mimic your C++ constants. The problem is that now you have two
sets of "constants" to maintain.

Hope that helps.

--Sim
Sim, thanks for your reply! No, I didn't mean the Intellisense. I
meant a text file (instead of a binary file, such as DLL) that is
displayable in IDE with all the structures and constants defined in
there.

I expect that users of my DLL could reuse the declarations coming with
the DLL either in the form of header file or some other way that's
acceptable by both C++ and C#.
Mar 16 '07 #3
Dv,

You can't. You have to declare the structures that the functions use in
C#. Your best bet would be to declare them in the assembly that utilizes
the DLL functions in C#.

You can not use the same header file in C++ as you do in C#, and
vice-versa.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Dv" <de****@gmail.comwrote in message
news:11**********************@d57g2000hsg.googlegr oups.com...
>I have a API lib (written in C/C++) that can be used by C/C++ project.
Now, I'm adding support to C# project.

I changed the Lib to DLL. This is easy. However, I have no idea how to
deal with the structures and constants that used to be defined in the
header file of the lib.

Where should I define them that they can be commonly used by the DLL, C
++ and C#, and also is readable to their developers from their IDEs?

Thanks!
-Dev

Mar 18 '07 #4

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

Similar topics

7
by: mescaline | last post by:
Hi, Suppose a_file.cpp contains a function a_function() Now to include it in main_file.cpp I just do #include "a_file.cpp" and I'm all set. i recently came across this seemingly roundabout...
2
by: Rakesh | last post by:
Hi, I was writing this C++ program wherein I used an include statement like - #include <iostream.h> I was told by my co-worker that this form of including a file is deprecated and should...
28
by: Ramesh | last post by:
Hi, I am currently maintaining a legacy code with a very very large code base. I am facing problems with C/C++ files having a lot of un-necessary #includes. On an average every C/C++ file has...
18
by: Tuckers | last post by:
My question is, if I have created my own library which lives in its own install directory, to refer to its header file is it better to use #include "MyLibrary.h" or #include <MyLibrary.h> ...
60
by: Derrick Coetzee | last post by:
It seems like, in every C source file I've ever seen, there has been a very definite include order, as follows: - include system headers - include application headers - include the header...
9
by: bill | last post by:
Forget the exact definition of difference between, #include <foo.h> and #include "bar.h" Normally foo.h is a standard header file, so it's path is not defined in compiler option, but I...
44
by: Neil Cerutti | last post by:
In Rob Pike's style guide he urges the following: Simple rule: include files should never include include files. If instead they state (in comments or implicitly) what files they need...
14
by: Jon Rea | last post by:
I am currently cleaning up an application which was origainlly hashed together with speed of coding in mind and therefore contains quite a few "hacky" shortcuts. As part of this "revamping"...
2
by: key9 | last post by:
Hi all look at the organize tree main.c ------ #include lib_adapter.c main() { foo();
8
by: The Cool Giraffe | last post by:
One thing i do know for sure. When one creates a CPP file, one needs to include the H file. Now, having said that, i wonder if there are some general hints, requirements or standard guide lines on...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.