XCode does not recognize quite obvious C++ syntax errors
I just found that some obvious syntax errors have not been picked up by XCode (version 3.2.3). My application is using a combination of Obj-C (for interface) and C++ (for the rest of the app). Here's an example:
class Bike
{
Bike (Bike ©, boolean v) { .. }
Bike (boolean v) { .. }
}
class Data
{
static *Bike findBikeByID (int id) { .. }
}
the call in question looks like this:
void function ()
{
Bike item = Data::findBikeByID (12开发者_运维技巧3); // error
// correct code (Data::findBikeByID returns a pointer, not a reference)
// Bike * item = Data::findBikeByID (123); // correct
}
Another bug it failed to report is this:
void function (Bike *input)
{
Bike *b = new Bike (*input); // error, should pass 2 arguments
}
the Bike (Bike ©, boolean v) takes two parameters in constructor. It might got confused with the 2nd constructor Bike (boolean), however even when I specify:
Bike *b = new Bike ((Bike &)*input);
it fails to notice any problems.
Any ideas why this is happening? Are there any compiler settings that control this?
精彩评论