April 23, 2024, 10:51:13 PM

News:

Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........


Can I cast without dereferencing?

Started by Parker, November 17, 2005, 04:55:08 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Parker

When I try to use the following code
value += (int)str[i];
it gives me a "Syntax error - int". I know that this conversion is done automatically, but in some other cases it is necessary to do this. I've tried the operators **, #, ##, and just (typename), but none seem to work. Is there something I'm missing, or is it not implemented yet?

Ionic Wind Support Team

Give me a case where automatic conversion doesn't cut it and I'll make it work ;)

Paul.
Ionic Wind Support Team

Parker

If I'm calling a function with variable arguments and I want it to cast a BYTE to an INT before calling, the compiler won't know that. I haven't needed it yet, but maybe someday. It also makes code easier to read, I think.

Ionic Wind Support Team

Anything less than 32 bits is sent as an INT on the stack.  So when you pass a byte it still takes up 32 bits anyway.

Paul.
Ionic Wind Support Team

Parker

How about this:
m_pFile = new(byte, GetFileLength(file)+1);
I get an integer value expected error.

I realize this can be fixed with automatic casting though.