[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference turris::c_plus_plus

Title:C++
Notice:Read 1.* and use keywords (e.g. SHOW KEY/FULL KIT_CXX_VAX_VMS)
Moderator:DECCXX::AMARTIN
Created:Fri Nov 06 1987
Last Modified:Thu Jun 05 1997
Last Successful Update:Fri Jun 06 1997
Number of topics:3604
Total number of notes:18242

3515.0. "TYPEXPR error ?" by SWETSC::EKLUND (On a clear day you can see forever) Wed Mar 26 1997 07:53

    Hi,
    
    Can somebody please tell me why I get the TYPEXPR error ?
    
    This is on Alpha VMS V6.2 with C++ V5.5-016. 
    
    The code is in .1 and the .H file in .2.
    
    regards
    Johan
T.RTitleUserPersonal
Name
DateLines
3515.1code.cxxSWETSC::EKLUNDOn a clear day you can see foreverWed Mar 26 1997 07:5579
//
//  DESIGN ISSUES:
//
//	A (part of a) character string is formatted according to the
//	formatting rule = AN (Account Number).
//
//	- A space is inserted between multiples of 4 characters,
//	  e.g. account number '12345678901234' will be formatted to
//	  '1234 5678 9012 34'
//	
//  INPUT PARAMETERS:
//
//	argString	A character string, where a part of it shall
//			be formatted
//	currStartPos	Start position in 'argString' where the
//			formatting shall start
//	length		Number of characters that shall be formatted
//	
//  OUTPUT PARAMETERS:
//
//	argString	Is now containing the result of the formatting
//	length		Number of characters after the formatting.
//			E.g. if the formatting did result in inserting
//			three spaces in the character string,
//			the output length is 3 greater than the input length.
//
//  CREATION DATE:  1997-01-27
//
//  RETURN VALUE:
//
//      TRUE		Successful execution

//--
//
//  INCLUDE FILES
//

#include <stdio.h>				// TRUE/FALSE
#include "Utility_FormatString.h"

int Utility_FormatAccountNumber	(char*	    argString,
				 const int  currStartPos,
				 int&	    length)

{
    int		toInsert;	    // Number of spaces that shall be inserted
    int		index;
    int		anInt;		    // An integer

    //
    //	Calculate the number of spaces that shall be inserted
    //	

    toInsert = (length - 1) / 4;    
				
    for (index = length; toInsert > 0; index--)
    {				
	// Start at the end of the current string and move characters
	// forwards, until it is time to insert a space. 
	// Then continue moving characters again and so on.
	
	argString [currStartPos + index + toInsert] 
	= argString [currStartPos + index];
	//
	// If index = 4, 8, 12, 16 etc, then it is time to insert a space
	// 
	anInt = index % 4;    
	if (anInt == 0)
	{
	    argString [currStartPos + index + toInsert - 1] = ' ';
	    toInsert--;
	    length++;
	}
    }
    return TRUE;
}
//------------------------------------------------------------------------------

    
3515.2utility_formatstring.hSWETSC::EKLUNDOn a clear day you can see foreverWed Mar 26 1997 07:5663
// Utility_FormatString.h
// Inneh�ller deklarationer f�r  Utility_FormatString.cxx och
// dess underfunktioner

#ifndef Utility_FormatStringINCLUDED
#define Utility_FormatStringINCLUDED

   const int	maxParams = 50;		// max number of unnamed parameters to
				        // the function Utility_FormatString
   const int	maxLength = 1000;	// max length of the output message

// If you change the value of maxLength, you should also change the hardcoded
// values concerning the length of the raw text in Utility_GetRawText.Pcx.
// These values are defined in embedded SQL statements and therefore 
// maxLength cannot be used.

struct	paramTable
{  char	       type [3];		// 2 chars + NUL
   char	       formatRule [3];		// 2 chars + NUL
   int	       startPos;
   int	       noOfChars;
};

//
// P R O T O T Y P E S
//

int Utility_FormatString	 (const char*	      language,
				  const char*	      msgName,
				  const int	      msgLength,
				  char*		      message,
						      ...);

int Utility_GetRawText		 (const char*	      language,
				  const char*	      msgName,
				  char*		      rawText);

int Utility_SearchForParameters	 (const char*	      rawText,
				  paramTable*	      theParamTable,
				  int&		      highestIndex);

int Utility_AccessArguments	 (va_list&	      ap,
				  paramTable*	      theParamTable,
				  int		      highestIndex,
				  char*		      argString);

int Utility_ReplaceParameters	 (const	char*	      rawText,
				  const	char*	      argString,
				  const	int	      msgLength,
				  const	paramTable*   theParamTable,
				  char*		      message);

int Utility_FormatAccountNumber	 (char*		      argString,
				  const int	      currStartPos,
				  int&		      length);

int Utility_FormatMoney		 (char*		      argString,
				  const int	      currStartPos,
				  int&		      length,
				  const double	      fpValue);	

#endif
    
3515.3SPECXN::DERAMODan D&#039;EramoWed Mar 26 1997 10:5818
        Which line does the error message point to?
        
#include <stdio.h>				// TRUE/FALSE
        
        Are TRUE/FALSE really defined in <stdio.h>?  According to the
        ANSI/ISO C standard they aren't.  You might need to add
        
#ifndef TRUE
#define TRUE 1
#endif
        
#ifndef FALSE
#define FALSE 0
#endif
        
        to your .cxx or .h file.
        
        Dan
3515.4I think the problem is va_listDECC::J_WARDWed Mar 26 1997 11:036
I think the problem is that although va_list is declared
as a char* typedef in stdarg.h, somewhere else (in one of the
include files brought in by stdio.h) it is declared as
an actual variable. If you put an include of stdarg.h
before the include of stdio.h, then it seems to work ok.
3515.5Thanx, buglet or what ?SWETSC::EKLUNDOn a clear day you can see foreverWed Mar 26 1997 11:237
    Hi and thanx to both.
    
    Yeah, it worked including stdarg before stdio.
    
    Beeing a C++ ignorant, is this really correct or a buglet ?
    
    -Johan
3515.6buglet?DECC::J_WARDWed Mar 26 1997 11:278
Well, it's not a bug in the C++ compiler, but
it does seem like it might be a problem with the
VMS C headers... I didn't investigate fully where the
other (conflicting) declaration of va_list is or what the C 
library standard has to say about va_list.

Perhaps someone better informed may know.
3515.7I do not see anything incorrectTLE::D_SMITHDuane Smith -- DEC C RTLWed Mar 26 1997 14:589
    The header file <utility_formatstring.h> uses va_list, but does nothing
    to ensure that this type is actually defined.  While this may not have
    been a problem on another system, I believe that it was "by chance"
    that va_list was defined by <stdio.h>.  In a strict ANSI compilation
    mode, va_list can only be defined by either including varargs.h or
    stdarg.h.
    
    To me the correct edit is to include <stdarg.h> in the header file
    which uses va_list.
3515.8Thank you allSWETSC::EKLUNDOn a clear day you can see foreverThu Mar 27 1997 03:015
    Hi,
    
    Thanx a lot the explanation.
    
    -Johan