Page 1 of 1

PostPosted: Tue Apr 20, 2004 7:26 pm
by kpeters
Hi all ~

compiler claims to be 'confused in expression' on the const keyword.
Something I don't understand - according to the help, this should work, but it seems to be way too trivial to be a bug - so what am I doing wrong?


string RegularChars(string s)
const string ALLOWED = "?ɬº?ɬ©?ɬ¢?ɬ§?ɬ†?ɬ•?ɬß?ɬ™?ɬ´?ɬ®";
int i;
string Result = "";


PostPosted: Wed Apr 21, 2004 1:26 am
by dewey
PocketC does not support 'const'

PostPosted: Wed Apr 21, 2004 1:49 pm
by kpeters
Hmmm - below is a snippet from the help claiming full support for 'const'. Also, the editor recognizes the const keyword and colorizes it - something needs to be fixed then, preferably the compiler :)

Constants and Enumerations

It is often useful to give names to important constants. This makes source code more readable. You can do this by defining a constant using the const keyword, or by creating an enumeration using the enum keyword. A constant is defined the same way a variable is, but begins with the const keyword. A constant can only be created for the five simple types. For example:

const float pi = 3.141592;
const string version = "1.0";

PostPosted: Wed Apr 21, 2004 3:22 pm
by Mikael
What's wrong with just using something like:

#define CLICHE "Head 'em off at the pass!"


#define NUMPEOPLE 2456

etc, in your globals?


PostPosted: Thu Apr 22, 2004 1:47 am
by dewey
const is supported in OrbC (the help file you quoted is from OrbForms Designer). You posted in the PocketC forum, which is why I assumed you were talking about PocketC.

The problem here is that const definitions must be at global scope, so take the definition outside the function and you are set.