Mail Archives: djgpp/2004/04/05/06:15:15
Chris <chris_tebbe AT yahoo DOT com> wrote:
> What is the proper way to use the GrLineOption?
In case of doubt: the one shown in the GRX docs.
> Snippet of GrTest.cc
> GrLineOption opt = {GrWHite(), 1, 2, "\x06\x04"};
This should work:
unsigned char pattern[] = { 6, 4};
GrLineOption opt = {GRWhite(), 1, 2, pattern};
Note that I replaced the string literal with an aggregate initializer.
Initializing what is going to be treated as an array of numbers by a
string using '\x..' notation all the way through is misleading.
> "Invalid conversion from 'const char*' to 'unsigned char *'."
The basic problem is that the struct field is a pointer to char,
but a string literal is effectively 'const'.
A C compiler usually wouldn't have bothered about this as long as the
code using this struct doesn't actually modify the data stored in the
pattern array, but you're compiling this as C++, which has
considerably stricter rules about implicit pointer casts, so you get
an error.
C++ may even offer some way of avoiding the explicit named variable
"pattern" by creating an anonymous object on the spot --- Java does.
--
Hans-Bernhard Broeker (broeker AT physik DOT rwth-aachen DOT de)
Even if all the snow were burnt, ashes would remain.
- Raw text -