A rather comprehensive site explaining the difficulties and solutions involved in using a dll written in c/c++ and the conversion of the .h header file to delphi/pascal was posted to a mailing list I was on recently, so I thought I'd share it, and invite others to post other useful resources for this, whether they be links, conversion tools, or book/paper titles.
One resource per answer please, so we'll end up with the most popular/best resources bubbling to the top.
Over at Rudy's Delphi Corner, he has an excellent article about the pitfalls of converting C/C++ to Delphi. In my opinion, this is essential information when attempting this task. Here is the description:
This article is meant for everyone who
needs to translate C/C++ headers to
Delphi. I want to share some of the
pitfalls you can encounter when
converting from C or C++. This article
is not a tutorial, just a discussion
of frequently encountered problem
cases. It is meant for the beginner as
well as for the more experienced
translator of C and C++.
He also wrote a "Conversion Helper Package" that installs into the Delphi IDE which aids in converting C/C++ code to Delphi:
(source: rvelthuis.de)
His other relevant articles on this topic include:
Using C++ Objects in Delphi
Using C object files in Delphi
Article at Rudy's Delphi Corner
Also, CodeGear hosts a rudimentary translation tool called CToPas (written by Ural Gunaydin).
I would like to highlight the Jedi Api Library, it is the Delphi translation of the Windows SDK headers. Might save you a lot of work if you need to translate headers from the SDK and is of course a good sample of conversions!
Since FreePascal is aimed at Delphi compatibiltiy among other things, i think H2Pas may be helpful too.
https://www.freepascal.org/tools/h2pas.var
HeadConv from DrBob is used quite a lot too, although I concur with Graza that manual translation is best.
use this option so the byte alignment is the same as C/C++ and then you don't need to add padding bytes in structs.
{$MINENUMSIZE 4}
Related
Is there a good, simple library which allows C++ to load a webpage? I just want to grab the source as text. I'm not using any IDE or significant library, just straight command line.
Tangentially, is there something fundamental I'm missing about programming in C++? I would think any language in common use today would have droves of web-based functionality, being so central to computer usage, but I can find next to no discussion on how to accomplish it. I realise C++ significantly predates the modern internet, so it lacking any core ability in the regard is reasonable, but the fact that relevant libraries seem so sparse is baffling.
Thanks for your help.
Sure, for example libcurl is powerful and popular.
Internet-related libraries for C++ are extremely abundant -- they're just not part of the C++ standard, partly because the current version of that standard is so old, though I'm sure that's not the only reason. But turn to the world of open sources and you'll find more than you can shake a stick at.
libcurl is a popular C library for fetching HTTP and other URLs. There's also cURLpp a C++ binding .
On Windows you have the WinINet and WinHTTP APIs.
I think HTTP is a bit too complex to be part of the C++ Standard Library. The specification would have to take a lot of details into account such as proxy servers and MIME types.
I am more into C/C++. But many of my seniors here in college ask me to learn Java if I want to contribute to an open source project.. I'm in dilemma. what to do? Can't we do a design project in C/C++?
There are plenty of open source C and C++ projects - as well as loads in virtually any other language you can come up with.
Of course it's never a bad idea to learn another language, but don't feel too constrained by "only" knowing C and C++.
If you want to contribute to a specific open source project which is written in Java, of course, that's a different matter... but if you're trying to find C and C++ open source projects, some of the major hosting sites support querying by project language, I believe. For example, you can look at Google Code C++ projects and SourceForge projects tagged C++.
is it necessary to learn java for contributing to an open source project?
#: No
what to do??
#: Do whatever you are passionate with
Can't we do a design project in c/c++??
#: Of course you can, lots of non-java projects out there
Select an interesting C or C++ project and contribute to it. For example look at Tortoise SVN - it's in Visual C++, it's widely used, it's actively developed and its authors accept any useful contributions.
Not unless you want to participate in a Java project, and then again, you can learn it pretty quick if you know C++.
It would only be necessary to learn java if the open-source project you want to contribute is in java. There are so many open-source projects in c/c++ as well. The great example is Linux
If you are good at c/C++ there are plenty of OS projects in c/c++.
They are also fair amount of project in Dot Net and c#.
Contribute where you are strong...
It up to you in which domain you would like to be an expert, so select an open source project based on your interests and start contributing to that domain which would definitely help you in future.
You should also have the fundamental knowledge of other technologies so to learn a new thing is always good.
It up to you in which domain you would like to be an expert, so select an open source project based on your interests and start contributing to that domain which would definitely help you in future.
You should also have the fundamental knowledge of other technologies so to learn a new thing is always good.
Yes, you could contribute in areas like documentation/setup/deployment issues if not.
Is there an equivalent to tidy for HTML code for C++? I have searched on the internet, but I find nothing but C++ wrappers for tidy, etc... I think the keyword tidy is what has me hung up.
I am basically looking for something to take code written by two people, and clean it up to a standardized style. Does such an app exist?
Thanks a bunch!
Artistic Style
is a source code indenter, formatter,
and beautifier for the C, C++, C# and
Java programming languages.
GC Great Code
is a well known C/C++ source code
beautifier.
Of course I find an answer to my own question moments later. What luck, I probably spent an hour searching earlier.
Should anyone be looking for the same thing, check out Uncrustify at http://uncrustify.sourceforge.net/
If you're using Visual Studio then you could take a look at StyleManager*. It's a VS add-in that makes it easy to set up formatting styles and apply them to code whenever you need to. It's a popular choice with VS users, and in particular was used by the DirectX SDK team to tidy up their sample code.
*Huge disclaimer: I'm one of the authors of this software, so apologies for the shameless plug!
You can tidy your code online, with this website:
https://codebeautify.org/cpp-formatter-beautifier
https://codebeautify.org/cpp-formatter-beautifier
What are the alternatives for SOAP development in C++? Which one do you prefer and is most supported/modern?
Check out Apache Axis. That is my all times favorite SOAP implementation. It's SOAP done right! Exists for C++ and Java.
http://ws.apache.org/axis/
And in best traditions of Apache Foundation, it is FREE and OPENSOURCE.
So, enjoy!
I had to make SOAP calls for a project a while ago and the only acceptable solution I found was GSOAP.
http://www.cs.fsu.edu/~engelen/soap.html
It supports both C and C++ code, although working with C++ is nicer and easier to understand. It worked ok although there was an incompatibility with our WCF web service which meant we had to manually edit the automagically generated source code.
I stumbled on gsoap awhile ago, but I wasn't a huge fan of its interface and code generator. And as I remember it, the documentation is significantly lacking (or at least in a very difficult format).
Sometime in the near future, though, this library may be adding sockets support. At least, I suggested it to the developer some time ago and he seemed to think it was the idea, and a few months later an XML parser showed up in the API. I'm a big fan of that library, and would definitely use it more if it wasn't GPL.
If you are writing for Windows, Microsoft has a utility that comes with the Windows 7 SDK (And visual studio 2013 and later) called WSUTIL. It generates C proxies given a WDSL file, as shown in this example.
http://msdn.microsoft.com/en-us/library/windows/desktop/gg288974.aspx
KD Soap if you are in Qt C++. This is the URL
https://www.kdab.com/kd-soap/
SmartWin++ have a side-project called SmartSOAP which is pretty neat I think, it features a pretty complete stack starting from SocketStream, working its way up to HttpRequest/Response objects. Features a small (to the job) XML DOM class abstraction and goes up to SOAP. It even comes with a WSDL parser to create proxy classes for you. It heavily uses templates and STL. And is pretty awesome C++. Works on Windows Mobile...
Though it isn't extremely rich, doesn't feature stuff like SSL and such. But since the code is pure art I would guess it could easily be understood and extended upon yourself...
License is New BSD...
Disclaimer; I implemented it...
I was a C++ developer (mostly ATL/COM stuff) until, as many of us, I switched to C# in 2001. I didn't do much C++ programming since then.
Do you have any tips on how to revive my C++ skills? What has changed in C++ in the last years? Are there good books, articles or blogs covering the language. The problem is that most material I could find either targets people who are new to the language or those with a lot of experience.
Which C++ libraries are popular these days? I guess I will need to read on the STL because I didn't use it much. What else? Boost? ATL? WTL?
Boost - though it, and other libraries were around back then, its only relatively recently that it's taken off in a big way. Google for TR1 and c++0x standards too. You should defintely read up on STL because (IMHO) its the thing that makes C++ special.
ATL is as good a dead technology (don't get me wrong, I liked it and still use it somewhat, but its not fashionable in the MS world anymore).
Something like QT is probably more new and cool for C++ developers, and has the advantage of getting you into all the new Linux and web development that'll be increasingly popular over the next few years.
However, once you start looking at the things you can do, I think it'll all come back quite quickly.
I personally find that syntax is where i mostly need to catch up when i wander back to a language i havent used in a long time. But the concepts and what the language is about stays the same in memory.
Assuming its the same with you, i would say its a good idea to relook at the texts you remember to have been useful to you while learning C++. I would recommned Thinking in C++ for getting up fast on the syntax.
STL would be really useful yes. Thats one thing i have found commonly appreciated by all mature C++ programmers. It would be useful to know the libraries that Boost provides.
The changes to C++ world, depends on the changes your favourite compiler has decided to implement. Since you mentioned ATl/COM i assume it would be VC++. The changes to MFC would be support for Windows Forms (2005 vc++) and Vista compliant uI's and ribbon support(?) (2008 Vc++)
VC++ now supports managed C++ -i'm sure you know what that is coming from the C# world - 2008 adds supports for managed STL too.
VC++ is trying to be more standards compliant and are making some progress in that area.
They have introduced lots of secure functions that depreciate the old stds like strcpy and the compilers will also give warnings if you use the old fns.
VC++2005 also has something called function attributes, which it uses to describe the parameters so that it can do more checking on the inputs you pass in and statically flag a warning if it sees soething amiss. Usefuli would say though our shop has not progressed to using the 2005 compiler.
MSDN has the list of breaking changes for each releases. Oh & Support for Windows 95, Windows 98, Windows Millennium Edition, and Windows NT 4.0 has been removed from 2005 version of VC++. Additionally the core libraries you required till now (CRT, ATL, MFC etc) now support a new deployment model which makes them shared side sy side assemblies and requires a manifest.
This link should get you going - http://msdn.microsoft.com/en-us/library/y8bt6w34.aspx
2008 adds even more like Tr1 recommendations, more optimizning compiler, parallel compilation(/mp), support for new processor architectures etc. Open Mp support has also been enhanced in one of these versions is what i remember.
Again refer MSDN - thats the suthentic source for all the answers.
Good luck.
Definitely read the latest edition of "Effective C++" by Scott Meyers. I would also recommend "C++ Gotchas: Avoiding Common Problems in Coding and Design" by Stephen C. Dewhurst.
To sharpen your C++ skills I'd suggest going over some of your old C++ code if you still have access to it. Revisiting it will hopefully trigger those parts of your brain that have laid dormant after switching to C# :)
For libraries STL is good, then boost. I don't think there is too much new stuff going on with ATL/WTL from what you would have known back in 2001.
Just start a project. The libraries you use will depend on your project, but you should certainly read up on the STL. If you haven't used C++ for a long time you might need learn more about templates.
Pickup one of the C++ Unit Test frameworks out there (I suggest Google C++ Testing Framework, aka. gtest). Pick a small project that you can start from scratch and try some TDD. The TDD will encourage you to make small steps and to reflect on your code. Also, as you build your suite of unit tests, it gives you a base from which you can experiment with different techniques.
Rewrite some of your C# stuff using C++
For a start, I'd say try writing code that will work on both a Mac and Windows or Linux and Windows. This will force you to write code that is much more portable than the type of C++ code you can get away with on Visual C++ - there a lot of finer points that are very different when you go cross platform.
I'd suggest stay away from libraries for now if you can - perfect your ANSI C++ game first. I'd also suggest reading up on C++0x - the next standard is due soon and it would help you more to work towards that. To that end, brush up on the STL (the concepts behind it, not the implementation so much) and templates.
If you'd like to try BOOST, go ahead, but you can generally get by without using it. The reason I stayed away from it mostly is because of the way templates are used to do what is needed - a lot of which will become much easier once the new standard is introduced.
UPDATE: Once you're comfortable with the STL and start needing to do things that require a lot of code with the STL or are just plain tricky, then head over to BOOST. Buy a book on BOOST and read it and understand it well.
Take some old piece of code and add to it. This won't get you back on top of the latest C++ trends but it will get your feet wet.
At my job I had to add some features to a C++ ActiveX control and I hadn't touched C++ in years and years and have never done it professionally. Figuring out how to do it again was actually pretty damn cool.
I was in a similar situation: switched from C++ to C# in 2005 and then switched back to C++ in 2007. I can't say C++ universe really changed in those 2 years. The most crucial thing was to regain my memory-management instincts, but that can only be done by practicing.
Now that you have both C++ and .NET under your belt you might want to study C++ CLI a bit (new incarnation of late "Managed C++").
As for books, read everything with "Meyers" and "Sutter" on the cover.