Odd errors, msdn solutions not working

I'm rebuilding my old random mapmaker for homeworld 2 from scratch as an exercise in refining my programming practices. No copy paste, pure rewrite, splitting out multiple classes and reorganizing the code, trying to make it cleaner, more readable, and easier to add options.

I have a few supporting classes and a main menu so far and built it just to see if there was anything to fix before starting the big classes that are the meat of the project.

I ended up 126 errors, none of which make any sense. I've checked them all on msdn and gone over them with a fine tooth comb and not single one of these errors were what they say they are.

I'm hoping someone can give me some ideas of possible alternate causes of these (as I know sometimes the real error is elsewhere). I can't hook up my laptop to copy and paste this stuff, sorry, I would if I could.

For example, I'm getting c4430 (missing type specifier) on several data members, functions, and even a constructor, several of them get marked twice. They all have the type specifier.

c2761 (member function redeclaration not allowed), some of these aren't even overloaded and none are redeclared.

c3867 (function call missing arguement list), comes up on a function definition not a function call.

c2597 (illegal reference to nonstatic member) I don't even do anything with static vs nonstatic. All of these sem to be in function definition argument lists though, not sure why.

c2556 (overloaded function differs only by return type), except only one function here and return type is fine.

c2535 (member function already defined or declared), these are overloaded constructors with differing parameters though the default one comes up twice.

c2511, (overloaded member function not found in class) a few of these, all unique no overloaded versions. They take strings and my compiler can't seem to decide whether strings are are a type or not. It says they are fine, then during the build claims them as identifiers.

c2460 (uses class which is being defined), these multiple refer only to a single constructor. I can't find anything wrong with it and the overloaded versions are fine.

c2448 (function style initializer appears to be a function definition.) All in constructors, might be the data member initializers, but not all of them are marked as errors. Can't see what try changing though.

c2447 (missing function header)on an opening brace just after the function header.

c2352, (illegal call of nonstatic member function.) called just the same as other functions.

c2228 (left of .function must have class/struct/union) a bunch of these all refering to data members, some stand alone, others in a vector.

This line comes up several times on a number of errors,
string stringifyAll();
It is in the class declaration, and the return type comes up with a reg squiggly claiming to be an undeclared identifier, but only here.

Tons of syntax errors that are fine. I think I'd catch at least one if they were actually syntax errors.

Always start fixing the first error in the list, then recompile. Repeat until you have no errors left.

Often one error causes many more error messages to show up in later parts of the code. For instance if something is wrong with a function declaration you will get an error because of that. But you might also get an error message for every time you try to call the function because the function has not been declared correctly. It's like a chain reaction. That is why you should always start with the first error message. Fixing it will often remove a lot of the later error messages. You probably have a lot less than 126 real errors that need to be fixed in your code.
Last edited on
Hi,

I am not sure what level of knowledge you have, so I apologise in advance if what I am saying is way below your level :+)

I can't but help think that there could be a couple of things causing problems:

1 Are you sure that you have you included all the necessary header files?

2 Do you have using namepsace std; ? If so, you may have name conflicts. You had string stringifyAll(); , that is what prompted me to mention this.

It sounds like you have quite a bit of code, do you have it in your own namespace?

This is all a bit of guess - without seeing any code. Can you post the code associated with the first few errors? And post those errors verbatim. I can't remember how much VS gives one in this respect. I know you said you couldn't, but it is rather difficult to see what happening if you don't.

It is also a good idea to compile frequently, (you should be able compile individual files, as opposed to the entire project) so you can discover problems early and not let them propagate like Peter87 described.

I am not sure whether any of this is helpful, or whether I have related some stuff that you have known thoroughly for years :+)
First, I've gone over all the errors, aside from one that got fixed before I ever posted, I can't figure out what is wrong. I've already checked the things that supposedly are the cause but acheived nothing.

Second,
All headers are included, all using directives solid, even commented out my own namespace where I could do without it.

Third, the barrier to posting code is that internet access is only on my phone except occasional chances at school. Some idiot decided that a phone should only be able to act as a passthrough connection for your computer with a special phone plan that of course costs extra. That and my phone keyboard isn't really good for typing.

I'll post more details tonight/tomorrow morning.
Okay, I fixed most of them.

In class we only needed to include files in the header. It worked in class (implementation dependant maybe?). The interface accepts that and even gives proper tooltips and right click menus, but I included the include files in both headers and cpp files and that made a few of the compile errors go away.

Renaming some functions did the biggest help and cleared most of them. Thanks for suggesting that.

I found a workaround for c2536, If you include,
#include <array>

Then you can declare an array like so,
std::array<int, 3> arrayName;

Then initialize like so,
class::class (a,b,c) : arrayName({{a,b,c}}) {}

Requires the double brackets to work for some reason. That solved most of the remaining errors leaving just one type left.

Now, just one error type remains,
c2440: 'initializing': cannot convert from 'initializer-list' to 'std::string'

I've got an array of strings for displaying when called, but it keeps throwing this error. I tried const and/or static in every combo. The function that uses it isn't in a class so I can't make it a data member. Any ideas on this one? I don't need it modifiable at runtime if that helps.
Okay, after looking around, I bypassed the issue by completely rearranging things and used a trick I found.

In the header I did this,
static const string bob(int index){
static const string fred[ ] = {
"text",
"text"};
return fred[index];
}//close bob

Then just call it like a function named bob.
Not c&p here, but I got it to compile and run.
Last edited on
Topic archived. No new replies allowed.