IBM Support

How to change the header file inclusion order using Post Processing script in Rational Rhapsody

Technote (FAQ)


How do you change the header file inclusion order using Post Processing script in IBM Rational Rhapsody?


You would like to use a C++ script to modify the generated code as per your specific requirement, which is not directly possible using the GUI.


In order to change the header file inclusion order, you can use the below C++ post processing script as a reference. This script changes the order of a class self and dependency includes.


All source code and/or binaries attached to this document are referred to here as "the Program". IBM is not providing program services of any kind for the Program. IBM is providing the Program on an "AS IS" basis without warranty of any kind. IBM WILL NOT BE LIABLE FOR ANY ACTUAL, DIRECT, SPECIAL, INCIDENTAL, OR INDIRECT DAMAGES OR FOR ANY ECONOMIC CONSEQUENTIAL DAMAGES (INCLUDING LOST PROFITS OR SAVINGS), EVEN IF IBM, OR ITS RESELLER, HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.

#import "C:\IBM\Rational\Rhapsody\761\rhapsody.tlb" raw_interfaces_only, no_namespace, named_guids

#include "stdio.h"
#include <string>
#include <conio.h>
#include <iostream>
#include <fstream>

using namespace std;

static void process( const char* filename ) {

 string lineString, tmpString, fileString;
 int flag = 0;

 fstream in( filename );

 if ( !in ) {
  cout << filename << " does not exist!" << endl;
 } else {

 while ( getline(in, lineString,'\n')) {

 if(std::string::npos != lineString.find(".cpp"))
  flag = 1;

 if(std::string::npos != lineString.find("//## auto_generated"))
  if(flag=1) {
   tmpString = lineString + '\n';
   getline(in, lineString,'\n');
   tmpString = tmpString + lineString;
   getline(in, lineString,'\n');

 if(std::string::npos != lineString.find("//## package"))
  fileString += tmpString + '\n';

 fileString += lineString + '\n';


 ofstream out(filename, ios::ate );
 out << fileString;


int main(int argc, char* argv[]) {

 char fileName[80];

 if ( argc > 1 ) {
  strcpy (fileName, argv[1] );
 } else {
  printf ("Missing arguments\n");
 return 0;

You need to convert the above code to an executable using any C++ IDE [say Microsoft Visual Studio 6] and use the same in the property CG::File::InvokePostProcessor

Document information

More support for: Rational Rhapsody
General Information

Software version: 7.5,, 7.5.1,, 7.5.2,, 7.5.3,,, 7.6,, 7.6.1,,

Operating system(s): Windows

Reference #: 1607429

Modified date: 29 August 2012