delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2004/04/05/06:15:15

X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f
From: Hans-Bernhard Broeker <broeker AT physik DOT rwth-aachen DOT de>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Help with GRX GrLineOption
Date: 5 Apr 2004 10:11:09 GMT
Organization: Aachen University of Technology (RWTH)
Lines: 37
Message-ID: <c4rbbt$her$1@nets3.rz.RWTH-Aachen.DE>
References: <b687bbff DOT 0404041302 DOT 5f38f97a AT posting DOT google DOT com>
NNTP-Posting-Host: ac3b07.physik.rwth-aachen.de
X-Trace: nets3.rz.RWTH-Aachen.DE 1081159869 17883 137.226.33.205 (5 Apr 2004 10:11:09 GMT)
X-Complaints-To: abuse AT rwth-aachen DOT de
NNTP-Posting-Date: 5 Apr 2004 10:11:09 GMT
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019