× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Hi, all.
I'm really new with C++ and recently while porting a program from ILE/C to
ILE/C++ ran into a strange effect that I cannot explain. Maybe someone can
help me.

Here's a simple program:

#include <stdlib.h>
#include <bcd.h>

int main (int argc, char *argv[])
{
char Day1[7], Day2[7] ;
_DecimalT<15, 0> v1, v2, v3, v4 ;

memset (Day1, '0', 7) ;
memset (Day2, '1', 7) ;

v2 = __D("100") ;
v3 = __D("10") ;
v4 = __D("200") ;

v1 = (memcmp(Day1, Day2, 7) <= 0) ? v2 - v3 - v4 : v2 - v4 ;

return(0) ;
}

Attempt to compile it produces error message for conditional assignment:
CZP0207 No common type found for operands with type "_DecimalT<17,0>" and
"_DecimalT<16,0>".

However when I change it (put a plain conditional statement):

#include <stdlib.h>
#include <bcd.h>

int main (int argc, char *argv[])
{
char Day1[7], Day2[7] ;
_DecimalT<15, 0> v1, v2, v3, v4 ;

memset (Day1, '0', 7) ;
memset (Day2, '1', 7) ;

v2 = __D("100") ;
v3 = __D("10") ;
v4 = __D("200") ;

if (memcmp(Day1, Day2, 7) <= 0)
v1 = v2 - v3 - v4 ;
else
v1 = v2 - v4 ;

return(0) ;
}

Program compiles fine without errors...

In ILE/C both compile, of course....

What is the difference?

TIA,

Jevgeni.

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.