byte *ConfigLoaderMessageString = new byte[1];
*ConfigLoaderMessageString[0] = (byte)MESSAGE_CONFIGLOADER;
As you can see I''m trying to malloc out a single byte then set byte zero to the value of the message id.
(byte is a typedef for unsigned char, MESSAGE_CONFIGLOADER is a member of an enum that will provide the messageID)
This code obviously doesnt work but it LOOK''s like it should. Any thoughts?
Here are the errors:
Gimp
c:\program files\microsoft visual studio\vc98\myprojects\orchid\common\commands\configloader.h(17) : error C2466: cannot allocate an array of constant size 0
c:\program files\microsoft visual studio\vc98\myprojects\orchid\common\commands\configloader.h(17) : error C2501: ''ConfigLoaderMessageString'' : missing storage-class or type specifiers
c:\program files\microsoft visual studio\vc98\myprojects\orchid\common\commands\configloader.h(17) : error C2372: ''ConfigLoaderMessageString'' : redefinition; different types of indirection
c:\program files\microsoft visual studio\vc98\myprojects\orchid\common\commands\configloader.h(16) : see declaration of ''ConfigLoaderMessageString''
c:\program files\microsoft visual studio\vc98\myprojects\orchid\common\commands\configloader.h(17) : error C2440: ''initializing'' : cannot convert from ''unsigned char'' to ''int *[]''
There are no conversions to array types, although there are conversions to references or pointers to arrays
Silly Question?
As part of my messaging engine I''m passing a hunk of ram to a function. The first byte is the message id. In many cases this consists of a single byte for example the command to ''load config file''. It''s pretty inefficient in places using a pointer to point at a single byte but required for consistancy.
Chris Brodie
Why not do:
byte *ConfigLoaderMessageString = new byte;*ConfigLoaderMessageString = (byte)MESSAGE_CONFIGLOADER;
If your making an array, shouldn''t it be a pointer to pointer of byte? Or maybe you want "= new byte;" ?
"If you have any questions you may direct
them to that brick wall over there." - South Park
"If you have any questions you may direct
them to that brick wall over there." - South Park
Thanks but even :
Gives the following error:
c:\program files\microsoft visual studio\vc98\myprojects\orchid\common\commands\configloader.h(18) : error C2501: ''ConfigLoaderMessageString'' : missing storage-class or type specifiers
c:\program files\microsoft visual studio\vc98\myprojects\orchid\common\commands\configloader.h(18) : error C2040: ''ConfigLoaderMessageString'' : ''int'' differs in levels of indirection from ''unsigned char *''
I feel like an idiot have trouble with a pointer to a single byte.... how basic is that?
byte *ConfigLoaderMessageString = new byte;*ConfigLoaderMessageString = (byte)MESSAGE_CONFIGLOADER;
Gives the following error:
c:\program files\microsoft visual studio\vc98\myprojects\orchid\common\commands\configloader.h(18) : error C2501: ''ConfigLoaderMessageString'' : missing storage-class or type specifiers
c:\program files\microsoft visual studio\vc98\myprojects\orchid\common\commands\configloader.h(18) : error C2040: ''ConfigLoaderMessageString'' : ''int'' differs in levels of indirection from ''unsigned char *''
I feel like an idiot have trouble with a pointer to a single byte.... how basic is that?
Chris Brodie
it compile fine on ms vc6++ when i replace "byte" with "BYTE".
( and #define MESSAGE_CONFIGLOADER 1 )
( and #define MESSAGE_CONFIGLOADER 1 )
Ries
Like Claus Hansen Ries said - you need a type definition of "byte" first...
typedef unsigned char byte;
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement