View unanswered posts | View active topics It is currently Wed May 22, 2013 8:01 am






Reply to topic  [ 3 posts ] 
compiler:struct pass by value autom conv 2 pass by reference 
Author Message
Senior Roboticist
User avatar

Joined: Sat Mar 01, 2008 12:52 pm
Posts: 936
Location: a small planet in the vicinity of Beteigeuze
Post compiler:struct pass by value autom conv 2 pass by reference
hi,
in the following code the compiler converts struct variables automatically to call by reference.

Actually, there is no need to do is - why is this happening?
Code:
const int nn = 100;
const int nd = 10;
const float thresh = 0.5;

typedef struct{
   float in[nd];
   float w[nd];
   float net;
   float t;
   float act;
   int out;
} tNeuron;


tNeuron Neuron[nn];

void initNeuron(tNeuron &neur){
   int d;

  for (d=0; d<nd; d++) {
    neur.in[d]=0;
    neur.w[d]=0;
  }
  neur.net=0;
  neur.t=thresh;
  neur.act=0;
  neur.out=0;
}

float netCalc(tNeuron neur){      // [31]
  int j=0;
  float s=0;

  for(j=0;j<nd;j++){
     s+= (neur.in[j]*neur.w[j]);
  }
  return s;
}

float actThr(tNeuron neur){     // [40]
   if (neur.act>=neur.t) return 1;
   else return 0;
}

Code:
[31] **Info***:Struct variable 'neur' automatically converted to call by reference
[40] **Info***:Struct variable 'neur' automatically converted to call by reference

_________________
Ford Prefect

Never purchase release 1.x ! (ancient programmer's wisdom)
"Don't argue with idiots. They'll drag you down to their level and then beat you with experience."


Wed Apr 16, 2008 3:24 pm
Profile
Senior Roboticist
User avatar

Joined: Sat Mar 01, 2008 12:52 pm
Posts: 936
Location: a small planet in the vicinity of Beteigeuze
Post 
anyone at home?
where is the support?

_________________
Ford Prefect

Never purchase release 1.x ! (ancient programmer's wisdom)
"Don't argue with idiots. They'll drag you down to their level and then beat you with experience."


Fri Apr 25, 2008 4:05 pm
Profile
Senior Roboticist
User avatar

Joined: Sat Mar 01, 2008 12:52 pm
Posts: 936
Location: a small planet in the vicinity of Beteigeuze
Post 
Reminder!

_________________
Ford Prefect

Never purchase release 1.x ! (ancient programmer's wisdom)
"Don't argue with idiots. They'll drag you down to their level and then beat you with experience."


Tue Apr 29, 2008 2:16 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 3 posts ] 

Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  



Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.