Look at the following code, does it contradict your 'opinion' ? It is quite easy to forget most extraneous stuff.
Code:#include<cstdio> #include<cstring> #include<string> using namespace std; int main() { string foo("Manasij"); //Do whatever you like with foo printf("%s",foo.c_str()); return 0; }
Ok, then... you carry on with him and I'll go make supper...
(We do this A LOT... someone asks a question and invariably it degenerates into the regulars here debating amongst themselves... I'm trying very hard not to get caught up in that anymore).
> However, whats the general consensus about the portability of C++.
Well you haven't listed any machines where C++ would not be available.
With the exception of very low spec embedded micro processors, C++ is just as widely available as C is.
> 01 ASCIINUM PIC ---,---,--9.99 VALUE ZERO. *> 14 byte ASCII data.
> 01 DECINUM PIC S9(14)V(4) COMP VALUE 0. *> 64 bit binary data.
> MOVE DECINUM TO ASCIINUM.
> MOVE ASCIINUM TO DECINUM .
> Should I look into the string class from C++?
Or even making your own classes called ASCIINUM and DECINUM (built on top of whatever you feel like).
Then if you choose to overload assignment operator, you can literally do
myDecinumVar = myAsciinumVar;
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
With C++ you have to use the same compiler because of C++ Name Mangling makes an DLL built for Compiler A not work with Compiler B.
The OP original post said he wanted better than that.
Tim S.
Exactly what I feared, but can C++ be written to be portable?
Right, I want a re-write, the question is what to write?
OK! So, using C++ instead of staying with standard C would allow easier and safer string handling.
I've got allot of info from you guys, and so I need to do some reading, writing, and testing. I will post back my progress, and thanks so much to all!
--
Ye Old Geek
Yes. You will probably have fewer portability problems with C++ programs... DLLs as pointed out might be another matter. There you will have to expose interfaces that are compatible with C, C++ and others... otherwise you are restricting yourself to C++ executables. You may want to give some thought to making your DLLs in C (C++ can work with them easily) and doing your main executables in C++ (where you can mess with your safer strings).
Oh you know, the usual stuff... keywords, brackets, braces, functions etc.Right, I want a re-write, the question is what to write?
Yes and No... The C++ Strings library is easier to use, but these are not standard C strings and will require conversion (eg. Mystring.cstring) every time you talk to anything but your own C++ libraries. In my opinion the benefit is dubious at best... (But I've been wrong before )OK! So, using C++ instead of staying with standard C would allow easier and safer string handling.
Well don't be a stranger... it's good to have people here with some programming background.I've got allot of info from you guys, and so I need to do some reading, writing, and testing. I will post back my progress, and thanks so much to all!
This is good, but also I understand not wanting to get caught up in it, as it does exhaust lots of energy. Although the more you guys debate the issues the more I benefit
Years ago, I worked with a group of guys for about ten years doing software development, and we would get into lots of heated debate, and knock-down drag-out arguments. On rare occasion one of us would take off in the middle of the day, swearing to never return, only to be back the next morning as if nothing happened. More often it was just the normal yelling and cussing and name calling, then a good time at lunch together, then back it again for the afternoon round.
Bottom line -- debate, arguing, and even some name calling is deemed good and useful in my eyes anyway, as long as no one gets hurt. This is how we ring it out, and get to the truth.
I need to build .dll's and .so libraries, and they must be callable from multiple other languages, so it appears that standard C is the only option to meet those requirements.
Wheelll, that might be how YOU do it ...Bottom line -- debate, arguing, and even some name calling is deemed good and useful in my eyes anyway, as long as no one gets hurt. This is how we ring it out, and get to the truth.
I know. It's just that you can get the same or better information by getting 6 independent replies to your inquiries. I'm just trying not to get (you) caught up in a cycle of asking a question then watching the fight...
Well I've built a rather large header file, libvue3.h
re-writing all the Cobol Record layouts into C struct's.
as well as the COBOL linkage into C vars and struct's
I also added all the main prototypes into the header file, with the necessary includes.
Then started on the libvue3.c with the necessary includes, and functions based on the prototypes, which were based on the COBOL ENTRY routines.
It took awhile, testing and changing parm/arg linkage, but it now compiles and links to a test COBOL application program. All parms are being successfully passed to the C library from the Cobol app and back again. Debug fprintf's actually prove this...
Now that the base structure of the new library actually compiles and links, I need to write the guts of each function, all in standard C ofcourse.
Thanks again for all you input!