Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3368: Cannot modify header information - headers already sent by (output started at /includes/bbcode.php:472)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3370: Cannot modify header information - headers already sent by (output started at /includes/bbcode.php:472)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3371: Cannot modify header information - headers already sent by (output started at /includes/bbcode.php:472)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3372: Cannot modify header information - headers already sent by (output started at /includes/bbcode.php:472)
OrbWorks Community Forum • View topic - New compile problems

New compile problems

Discuss PocketC for CE (including Desktop Edition)

Postby Glasswalker on Thu Aug 08, 2002 4:29 pm

Hello again, thanks for the speedy answer on that last one Guy...

I have revised my code with your instructions, I also just learned that PocketC supported Structs... so I have changed the code to use structs... but now I am getting another different compile error...

the error is "Expect ;"

and it is on the line "outval = nn[29-outputnum].value;"

the function this is used in is here:

nn_output_analog(int outputnum)
{
int outval;
outval = nn[29-outputnum].value;
return outval;
}

any ideas on that one?
Glasswalker
 
Posts: 47
Joined: Wed Mar 21, 2001 12:18 am
Location: Canada

Postby guy on Thu Aug 08, 2002 5:04 pm

I'd need to see the definition of the struct of which nn is a type and the declaration of nn.

The line itself looks OK.

I've used arrays of structs before with no problems.



Guy
[url]mailto:pcform@pcform.net[/url]
http://www.pcform.net
PocketC CE API interface: http://www.networkdynamics.net/PCForm.html#library
PCForm and CE API forum: http://www.networkdynamics.net/forum
Guy
[url]mailto:pcform@pcform.net[/url]
http://www.pcform.net
PocketC CE API interface: http://www.networkdynamics.net/PCForm.html#library
PCForm and CE API forum: http://www.networkdynamics.net/forum
guy
 
Posts: 879
Joined: Thu Dec 07, 2000 8:58 am
Location: United Kingdom

Postby Glasswalker on Thu Aug 08, 2002 6:34 pm

The definitions are as such:

struct neuron_s
{
int value;
int fired[30];
int weight[30];
}

neuron_s nn[30];

also, I would love to be able to nest structs... is it possible to do that in PocketC?

such as:

struct hand
{
int finger[5];
};

struct body
{
hand hands[2];
arm arms[2];
leg legs[2];
}

so that I can refrence man1.hands[1].finger[3]

(just a lame example, but it would be nice, especially in the neuralnet example)

thanks
Glasswalker
 
Posts: 47
Joined: Wed Mar 21, 2001 12:18 am
Location: Canada

Postby guy on Fri Aug 09, 2002 8:22 am

Was the omission of the semicolon at the end of the struct definition a typing error?

Yes, you can nest structs. The struct isn't automatically typedefed (and PocketC doesn't support typedef anyway) so your second struct should read:

struct body
{
struct hand hands[2];
struct arm arms[2];
struct leg legs[2];
} ;

I usually declare structs as:

struct _name {
thing thing ;
thing thing ;
} ;

#define NAME struct _name

and then use NAME as the type.

You should be aware that you can't use pointers to structs in the same way as in real C. Because PocketC's pointers are untyped, the compiler doesn't know how to resolve the field names.

Instead you can pass and receive structs as reference variables as in C++, or you can use indexing from the pointer:

a) All PocketC basic variables have a size of 1
b) Incrementing a pointer by 1 steps it by the size of a PocketC basic variable (all basic variables are the same size)
c) A struct is an array of PocketC variables where each element is of a different type.
d) Nested structs look like the inside struct being expanded into the outside struct.
e) The size of a struct is the number of elements in it.

So:

int iLoop ;

struct _fred {
int i ;
int j ;
} ;

#define FRED struct _fred

struct _thing {
int i ;
float f ;
string s ;
char c ;
FRED z ;
} ;

#define THING struct _thing
#define PTHING pointer

THING t ;
PTHING p ;

t.i = 1 ;
t.f = 3.14 ;
t.s = "apple" ;
t.c = 'B' ;
t.z.i = 2 ;
t.z.j = 3 ;

p = &t ;

showconsole() ;

for (iLoop = 0; iLoop < 6; iLoop++) {
putsl("" + p[iLoop]) ;
}

Will display:

1
3.14
apple"
B
2
3



Guy
[url]mailto:pcform@pcform.net[/url]
http://www.pcform.net
PocketC CE API interface: http://www.networkdynamics.net/PCForm.html#library
PCForm and CE API forum: http://www.networkdynamics.net/forum
Guy
[url]mailto:pcform@pcform.net[/url]
http://www.pcform.net
PocketC CE API interface: http://www.networkdynamics.net/PCForm.html#library
PCForm and CE API forum: http://www.networkdynamics.net/forum
guy
 
Posts: 879
Joined: Thu Dec 07, 2000 8:58 am
Location: United Kingdom


Return to PocketC for CE

Who is online

Users browsing this forum: No registered users and 2 guests

cron