Using C++ Code in BCX
Remarks :
Directives have been added to help implement a crude BCX version of a C++ class. This is not meant to be permanent, but can be useful for testing what must be done to make BCX output C++ code. I think at the moment for the most part it only emits C code.
Here is list of all temporary directives for C++ class work:
$CLASS/$ENDCLASS $NAMESPACE/$ENDNAMESPACE $USENAMESPACE $TRY $THROW $CATCH $ENDTRY
What little experimenting I have done indicates that many changes and additions will be required to make BCX emit useful C++ code. I believe these simple directives will help ease that.
Note that using the $CLASS, $ENDCLASS and $NAMESPACE directives will automatically set UseCpp = TRUE.
The Directives:
$CLASS <classname> ' comments allowed <C++ Class Code> $ENDCLASS <object_name, object_name2>
The code between the $class/$endclass directives must be real C++ class code without the "class classname {" and the ending "};".
Example of C++ class:
// *************************** C++ Version of CRectangle: // *************************** #include <iostream.h> class CRectangle { int x, y; public: void set_values(int a,int b) { x = a; y = b; } int area(void){return(x*y)}; } rect;
// ************************** BCX Version of CRectangle: // ************************** #include <iostream.h> $CLASS CRectangle int x, y; public: void set_values(int a,int b) { x = a; y = b; } int area(void){return(x*y)}; $ENDCLASS rect
$NAMESPACE <identifier>
translates to:
using namespace identifier;
Example:
$NAMESPACE stdtranslates to:
using namespace std;**************************
$TYPEDEF <simple one line C/C++ typedef>Example:
$TYPEDEF long(CALLBACK *CPP_FARPROC)(char *)translates to:
typedef long(CALLBACK *CPP_FARPROC)(char *);' **************************
Also added two new keywords 'NEW' and "DELETE' to be used with C++ classes. Basically these keywords when found will just be emitted in lower case.
Note also that BCX will abort the translation if you attempt to use either of these words without UseCpp being set to true using the -c commandline switch or the $CPP directive.
-----------------------------------------------------------URL of a good C++ tutorial: http://www.cplusplus.com/doc/tutorial/index.html
URL of C++ tutorial for C Users: http://www.4p8.com/eric.brasseur/cppcen.html#l17