[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

BCB 5.0 Compilation Issues

From: Alexander J. Oss
Subject: BCB 5.0 Compilation Issues
Date: Tue, 26 Mar 2002 22:42:22 -0500

Here are the rest of the things I encountered while getting cgicc 3.2.1 to
compile with Borland C++ Builder 5.0.

1.  Warnings of "Conversion may lose significant digits" on the middle three
lines of hexToChar() in CgiUtils.p:

  char digit;
  digit = (first >= 'A' ? ((first & 0xDF) - 'A') + 10 : (first - '0'));
  digit *= 16;
  digit += (second >= 'A' ? ((second & 0xDF) - 'A') + 10 : (second - '0'));
  return digit;

This has always annoyed me, but serves a valid purpose IMHO: calculations
take place as integers, which means you can indeed screw yourself
unintentionally when implicitly converting back to char.  If, however, you
declare digit as an int, and explicitly cast in the return, the warnings go
away, and your code self-documents the already-assumed-to-be-safe conversion
with the presence of static_cast:

  int digit;
  digit = (first >= 'A' ? ((first & 0xDF) - 'A') + 10 : (first - '0'));
  digit *= 16;
  digit += (second >= 'A' ? ((second & 0xDF) - 'A') + 10 : (second - '0'));
  return static_cast<char>(digit);

Do other compilers complain about this?

2.  The line:

  fDataType = dataType.empty() ? "text/plain" : dataType;

in the FormFile constructor causes a "Two operands must evaluate to the same
type" error.  However, I believe this is a compiler bug, since 5.16.3 says
"an attempt is made to convert each of those operands to the type of the
other", and I'd think the std::string constructor that accepts a char *
could be used to convert the character data to a std::string.  I must admit
I don't fully understand the detailed rules in that clause by which
compilers are supposed to make the attempt, though.

My solution makes the types of the operands explicitly the same:

  fDataType = dataType.empty() ? STDNS string("text/plain") : dataType;

...So it turns out these were the only two additional things.  And once I
made sure that all three of my toolkit static library, the cgicc static
library, and my application got rid of the darn -tWM (multithreading
enabling) compiler option, accessible only in the raw project configuration
file and not through the IDE, I no longer get the runtime GPF's--I'm running
my cgicc application just fine...!  Grr.  Ah well.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]