I'm maintaining an application that's been must run op Alpha OpenVMS (7.3-2) and Itanium OpenVMS (8.4). It's written in C++, compiler version is 6.5-046 on Alpha and 7.4-004 on IA64.
The issue I have is with LIB$SIGNAL(). As soon as it signals a fatal message, the program aborts.
First the code to reproduce this (as a DCL script that generates and builds the code):
$ create mtst.msg
.TITLE Message file for MTST
.IDENT 'VERSION 1.1'
.FACILITY MTST,1 /PREFIX=MTST_
.SEVERITY INFORMATIONAL
HELLO <Hello World> /fao_count=0
.SEVERITY SUCCESS
SUCCESS <Opdracht succesvol uitgevoerd> /fao_count=0
.SEVERITY WARNING
WHOOPS <Dit is een waarschuwing: !AZ> /fao_count=1
.SEVERITY ERROR
WHAAA <Oeioeioei dat was op het randje> /fao_count=0
.SEVERITY FATAL
AARGH <Nu is het helemaal mis> /fao_count=0
.END
$!
$ create msgtest.h
#define __NEW_STARLET 1
#include<lib$routines.h>
#include<stsdef.h>
#pragma extern_model globalvalue
extern unsigned long MTST_HELLO;
extern unsigned long MTST_SUCCESS;
extern unsigned long MTST_WHOOPS;
extern unsigned long MTST_WHAAA;
extern unsigned long MTST_AARGH;
#pragma extern_model relaxed_refdef
$!
$ create msgctest.c
#include<msgtest.h>
#include<stdio>
#include<stdlib.h>
int main(void) {
char* msgArgument = "Boe!";
printf ("Test: info message...\n");
LIB$SIGNAL(MTST_HELLO);
printf("\n");
printf ("Test: success message...\n");
LIB$SIGNAL(MTST_SUCCESS);
printf("\n");
printf ("Test: warning message...\n");
LIB$SIGNAL(MTST_WHOOPS, 1, msgArgument);
printf("\n");
printf ("Test: error message...\n");
LIB$SIGNAL(MTST_WHAAA);
printf("\n");
printf ("Test: fatal message...\n");
LIB$SIGNAL(MTST_AARGH);
printf("\n");
printf ("Einde test!\n");
}
$!
$ create msgtest.cpp
#include<msgtest.h>
#include<iostream>
#include<stdlib.h>
using namespace std;
#include <chfdef.h>
int main(void) {
char* msgArgument = "Boe!";
cout << "Using IOStream:" << endl << "Test: info message..." << endl;
LIB$SIGNAL(MTST_HELLO);
cout << endl << "Test: success message..." << endl;
LIB$SIGNAL(MTST_SUCCESS);
cout << endl << "Test: warning message..." << endl;
LIB$SIGNAL(MTST_WHOOPS, 1, msgArgument);
cout << endl << "Test: error message..." << endl;
LIB$SIGNAL(MTST_WHAAA);
cout << endl << "Test: fatal message..." << endl;
LIB$SIGNAL(MTST_AARGH);
// Next line is, of course, never displayed...
cout << endl << "Einde test!" << endl;
}
$!
$! Compile the message file
$ message mtst
$!
$! As a reference, build an executable using the C-source. Will always work both on Alpha and Itanium
$ cc/lis=[] /include=[] msgctest.c /warn=(disa=dollarid)/notrace
$ link msgctest,mtst /map=[]/cross/notrace
$!
$! Now build the C++ based exe.
$ cxx/lis=[]/reposi=[] /include=[] msgtest.cpp /warn=(disa=dollarid)/notrace/standard=strict_ansi
$! Using this compile statement it works on Itanium:
$! cxx/lis=[]/reposi=[] /include=[] msgtest.cpp /warn=(disa=dollarid)/notrace
$! Using this compile statement it fails again:
$! cxx/lis=[]/reposi=[] /include=[] msgtest.cpp /warn=(disa=dollarid)/notrace/define=(__USE_STD_IOSTREAM)
$ cxxlink msgtest,mtst /map=[]/cross/notrace
$!
The C-source always works and on Alpha both scripts work.
When compiling without the /STANDARD it works well on Itanium, but in the original program I had problems using iostream: I need ANSI there, but a compile with /DEFINE=(__USE_STD_IOSTREAM) brought back the original issue.
$r msgtest
Test: info message...
%MTST-I-HELLO, Hello World
Test: success message...
%MTST-S-SUCCESS, Opdracht succesvol uitgevoerd
Test: inwarningfo message...
%MTST-W-WHOOPS, Dit is een waarschuwing: Boe!
Test: error message...
%MTST-E-WHAAA, Oeioeioei dat was op het randje
Test: fatal message...
%CXXL-F-TERMINATING, terminate() or unexpected() called
$
What I expect is this:
$ r msgctest
Test: info message...
%MTST-I-HELLO, Hello World
Test: success message...
%MTST-S-SUCCESS, Opdracht succesvol uitgevoerd
Test: warning message...
%MTST-W-WHOOPS, Dit is een waarschuwing: Boe!
Test: error message...
%MTST-E-WHAAA, Oeioeioei dat was op het randje
Test: fatal message...
%MTST-F-AARGH, Nu is het helemaal mis
$
So... %CPP-?-WTF, help please :-/
Thanks in advance, Oscar
Note: in the original post I made yesterday, there was a different script with some more testcode like a try/catch. Of course that changed the testresult as user2116290 stated in his/her comment. I changed the DCL script to the original test to reproduce what I see in the originating app.