-7

I'm getting a error, such as

1>src\CarDrivingAids.cpp(35): error C2220: warning treated as error - no 'object' file generated
1>src\CarDrivingAids.cpp(35): warning C4100: 'wheel' : unreferenced formal parameter

The problem is that, another class where I use the same approach with method writing, there's no errors and it works perfectly.

Here's my header:

#include "CarWheel.h"
class CarDrivingAids
{
  public:
    CarDrivingAids(void);
    ~CarDrivingAids(void);
    void TractionControlSystem(CarWheel* wheel);
};

And cpp:

#include "CarDrivingAids.h"

CarDrivingAids::CarDrivingAids(void)
{
}

CarDrivingAids::~CarDrivingAids(void)
{
}

void CarDrivingAids::TractionControlSystem(CarWheel* wheel)
{
}

The error appears on TractionControlSystem method. Any sugestions on what I'm possibly doing wrong here? By the looks of it, it should be correct? I'm using msvc++2010 express.

JohnYouDontLike
  • 71
  • 1
  • 1
  • 8
  • Are you missing a semicolon at the end of the definition of `CarDrivingAids`? – Beta Nov 17 '14 at 15:36
  • But you have only a warning about unreferenced object! Take a look how to avoid it: http://stackoverflow.com/questions/3020584/avoid-warning-unreferenced-formal-parameter – Leo Chapiro Nov 17 '14 at 15:36
  • [Compiler Error C2220](http://msdn.microsoft.com/en-us/library/ksk5k0ta.aspx) – Mahesh Nov 17 '14 at 15:38

2 Answers2

4

The problem is that CarDrivingAids::TractionControlSystem is being called with a parameter wheel, but you're not (yet) using it within the function. This is only a warning, but your compiler is configured to treat warnings as errors, so no code is being generated.

You can either: complete the implementation of the function, or turn of "Treat warnings as errors".

brycem
  • 593
  • 3
  • 9
  • 1
    Or not name the parameter in the function definition, or explicitly ignore it with `(void)wheel;` – Mike Seymour Nov 17 '14 at 15:42
  • Thank you, it has been a half a year since I last touched c++ and quite some stuff have been forgoten by me. My english is also not perfect, so I'm not always following what the outpud log tell's me, especially on the error side. – JohnYouDontLike Nov 17 '14 at 15:43
1

Just as the error message reads: Warnings are treated as errors. wheel is not used in CarDrivingAids::TractionControlSystem() which is a warning normally. But in your case it is an error.

If you don't want warnings to be treated as errors, you can turn of this behaviour in the project properties. For VS 2013 you find this by right clicking the project, choose "Properties". Then "Configuration Properties / C/C++ / General / Treat Warnings As Errors".

TobiMcNamobi
  • 4,687
  • 3
  • 33
  • 52