Author Topic: Bug on function prototype  (Read 5205 times)

Offline chameleon

  • Multiple posting newcomer
  • *
  • Posts: 39
Bug on function prototype
« on: June 06, 2011, 02:04:25 am »
I doesn't use the nightly build of CodeBlocks but I found this error:
The same function prototype appears 2 times (a little bit changed)

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5906
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Bug on function prototype
« Reply #1 on: June 06, 2011, 01:53:02 pm »
can you give a simple test code?
From my guess, I think that this is because these two function prototypes has different signatures.

const class circleArc2 *c, const Vector & v
const circleArc2 *c, const Vector & v

But why the "class" keyword was exists in the function signature??

did you use 10.05 official version?


If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline nanyu

  • Almost regular
  • **
  • Posts: 188
  • nanyu
Re: Bug on function prototype
« Reply #2 on: June 06, 2011, 04:30:17 pm »
As far as I know, CC is not smart enough to do it for. For example: If I declare some member methods like:
Code
///////////////////////////
class Coo
{
    int foo1(int a, int b);
    int foo2(char const*);
    int foo3(int age /* some comment*/, int b);
};
///////////////////////////
and defind those methods like:
Code
int Coo::foo1(int a
       , int b)   //b start on a new line
{}

int Coo::foo2(const char* p)
{}

int Coo::foo3(int age, int bbb)
{}

then all of those function will appears 2 times on the tips windows.


Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Bug on function prototype
« Reply #3 on: June 06, 2011, 04:49:56 pm »
nanyu: you should be punished and humiliated in public for writing such code :lol:
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline nanyu

  • Almost regular
  • **
  • Posts: 188
  • nanyu
Re: Bug on function prototype
« Reply #4 on: June 06, 2011, 05:04:24 pm »
nanyu: you should be punished and humiliated in public for writing such code :lol:

no, no, no.....
look at the first sample:

I am used to add the comments of it's parameters when declare a function :
Code
int foo1(int aaa  //comments of aaa
             , int bbb   //comments of bbb
             , char const* ccc //comments of ccc
             , Coo const* ddd  //comments of ddd
             );

But  a clear version for imp :
Code
int foo1(int aaa, int bbb, char const* ccc, Coo const* ddd)
{
}

I thinks it was not a hard thing that cc do a filtting.
« Last Edit: June 06, 2011, 05:07:28 pm by nanyu »

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Bug on function prototype
« Reply #5 on: June 06, 2011, 06:35:07 pm »
This is a bug, no question about it :)
Apparently CC in its current implementation doesn't strip the names of the parameters.

But your code is ugly, too (don't answer me, I'm joking, trolling :lol: )
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline ouch

  • Almost regular
  • **
  • Posts: 223
Re: Bug on function prototype
« Reply #6 on: June 06, 2011, 08:18:34 pm »
hey now, be nice... I write code comments on everything like that too. Expecially stuff I'm debuging I'll comment bits out with /* */. Keeping things readable is  what syntax highlighting is for after all. :p