Click here to Skip to main content
15,891,409 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionConverting Fortran source to C++ Source Pin
manoharbalu9-Jun-16 1:58
manoharbalu9-Jun-16 1:58 
AnswerRe: Converting Fortran source to C++ Source Pin
Jochen Arndt9-Jun-16 2:30
professionalJochen Arndt9-Jun-16 2:30 
GeneralRe: Converting Fortran source to C++ Source Pin
manoharbalu9-Jun-16 2:52
manoharbalu9-Jun-16 2:52 
GeneralRe: Converting Fortran source to C++ Source Pin
Jochen Arndt9-Jun-16 3:27
professionalJochen Arndt9-Jun-16 3:27 
GeneralRe: Converting Fortran source to C++ Source Pin
manoharbalu9-Jun-16 3:36
manoharbalu9-Jun-16 3:36 
GeneralRe: Converting Fortran source to C++ Source Pin
Jochen Arndt9-Jun-16 3:54
professionalJochen Arndt9-Jun-16 3:54 
GeneralRe: Converting Fortran source to C++ Source Pin
leon de boer9-Jun-16 4:21
leon de boer9-Jun-16 4:21 
GeneralRe: Converting Fortran source to C++ Source Pin
David A. Gray13-Jun-16 11:35
David A. Gray13-Jun-16 11:35 
Since your existing libraries can be linked, you need not convert them all at once. However, if you really do intend to abandon the Fortran compiler, then convert them you must, eventually. However, C++ and Fortran are enough alike that the conversion may be simpler than you think. For instance, the control structures should be fairly straightforward. While you may have to visit each one briefly, I suspect that a lot of the conversion can be handled by editor macros or Perl scripts written around regular expressions.

If the libraries use PRINT and FORMAT statements, all of which will need to be completely rewritten to use something like sprintf(), you may not be able to do quite as much with automation, though I would explore it. It's been too long, and I've forgotten most of what I once knew about FORMAT statements, but it's quite possible that you can accomplish much of that conversion with regular expressions, too. Along that line, since they are essentially literal constants, consider replacing the FORMAT statements with #define macros or string resources, so that they incur little or no runtime overhead. There is a trade-off between #define macros and string resources.

A #define resolves to a constant that is baked into the code, and costs basically nothing to use.

A string resource requires a Windows API call (LoadString) every time you need a new pointer to the string. If you set your character set to Unicode and null terminate your string resources, LoadString can return a pointer to the string, right where it sits. There is a resource compiler option, settable in the project configuration, to null terminate your resource strings. Otherwise, you need a buffer of up to 4097 TCHARs to hold each string. Better yet, let MFC look after all of that by using its CString class, which even sports a LoadString method that looks after the memory for you.

Another potentially thorny issue is COMMON blocks, either blank or labeled. Blank common is essentially process global storage that must be externally linked, and is usually easiest to define as part of the source file in which main() is defined. If there are also labeled COMMON blocks, consider putting each into a static class. Regardless, the actual common block definitions should go into header files. If you surround them with preprocessor guard code, you can define the common blocks and the routines that use them in the same header. Using the guard code lets you get away with defining the same common block in two or more headers, even if the same program includes all of them.
AnswerRe: Converting Fortran source to C++ Source Pin
Richard MacCutchan9-Jun-16 3:42
mveRichard MacCutchan9-Jun-16 3:42 
AnswerRe: Converting Fortran source to C++ Source Pin
leon de boer9-Jun-16 4:10
leon de boer9-Jun-16 4:10 
QuestionC++ and Visual Studio help? Error messages etc.. Pin
User 125396568-Jun-16 8:19
User 125396568-Jun-16 8:19 
SuggestionRe: C++ and Visual Studio help? Error messages etc.. Pin
David Crow8-Jun-16 9:32
David Crow8-Jun-16 9:32 
AnswerRe: C++ and Visual Studio help? Error messages etc.. Pin
Richard MacCutchan8-Jun-16 20:53
mveRichard MacCutchan8-Jun-16 20:53 
AnswerRe: C++ and Visual Studio help? Error messages etc.. Pin
leon de boer8-Jun-16 21:57
leon de boer8-Jun-16 21:57 
GeneralRe: C++ and Visual Studio help? Error messages etc.. Pin
Richard MacCutchan8-Jun-16 22:26
mveRichard MacCutchan8-Jun-16 22:26 
QuestionMemory leak in VC++ 6.0 when store lots of objects in CArray,please help me! Pin
lostangels5-Jun-16 4:37
lostangels5-Jun-16 4:37 
AnswerRe: Memory leak in VC++ 6.0 when store lots of objects in CArray,please help me! Pin
Daniel Pfeffer5-Jun-16 21:39
professionalDaniel Pfeffer5-Jun-16 21:39 
AnswerRe: Memory leak in VC++ 6.0 when store lots of objects in CArray,please help me! Pin
Richard MacCutchan5-Jun-16 22:35
mveRichard MacCutchan5-Jun-16 22:35 
AnswerRe: Memory leak in VC++ 6.0 when store lots of objects in CArray,please help me! Pin
Victor Nijegorodov6-Jun-16 1:17
Victor Nijegorodov6-Jun-16 1:17 
AnswerRe: Memory leak in VC++ 6.0 when store lots of objects in CArray,please help me! Pin
leon de boer6-Jun-16 3:27
leon de boer6-Jun-16 3:27 
QuestionType checking Pin
Rahul Thengadi4-Jun-16 10:26
Rahul Thengadi4-Jun-16 10:26 
AnswerRe: Type checking Pin
leon de boer4-Jun-16 21:03
leon de boer4-Jun-16 21:03 
Questionwhat is the difference between definition numeric value 0.0, .0, 0.? Pin
Member 125258022-Jun-16 22:23
Member 125258022-Jun-16 22:23 
AnswerRe: what is the difference between definition numeric value 0.0, .0, 0.? Pin
Richard MacCutchan2-Jun-16 23:40
mveRichard MacCutchan2-Jun-16 23:40 
GeneralRe: what is the difference between definition numeric value 0.0, .0, 0.? Pin
Member 125258023-Jun-16 1:59
Member 125258023-Jun-16 1:59 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.