compiler-errors

Recommended gcc warning options for C

Other than -Wall what other warnings have people found useful? http://gcc.gnu.org/onlinedocs/gcc-4.3.2/gcc/Warning-Options.html ...

Expression inference during inheritance

I have the following code: using System; using System.Linq; using System.Linq.Expressions; public class Program { public static void Main() { Descendant d = new Descendant(); d.TestMethod(); } } public class Base { protected void FigureItOut<TClass, TMember>(Expression<Func<TClass, TMember>> expr) {...

Why do I get this error creating & returning a new struct?

I get an error when I compile this code: using System; public struct Vector2 { public event EventHandler trigger; public float X; public float Y; public Vector2 func() { Vector2 vector; vector.X = 1; vector.Y = 2; return vector; // error CS0165: Use of unassigned local variable 've...

Why C# compiler doesn't call implicit cast operator?

Suppose we have following type: struct MyNullable<T> where T : struct { T Value; public bool HasValue; public MyNullable(T value) { this.Value = value; this.HasValue = true; } public static implicit operator T(MyNullable<T> value) { return value.HasValue ? value.Value : default(T); ...

Why does C# limit the set of types that can be declared as const?

Compiler error CS0283 indicates that only the basic POD types (as well as strings, enums, and null references) can be declared as const. Does anyone have a theory on the rationale for this limitation? For instance, it would be nice to be able to declare const values of other types, such as IntPtr. I believe that the concept of const is ...

Compiler Error when adding dll reference to managed c++ project

Hello, I am using VS 2008 and get compiler errors sporadically when adding a dll reference to a managed c++ file in my C++ project. I am trying to add a reference to the dll so as to be able to use smart pointers. ex: #import items.tlb The problem is that the compiler crashes at sporadic places inside of items.tlh almost as though chun...

Why no compiler error?

I'm working on a C-brain teaser: Write the standard Hello-World program, without semi-colons. My best answer so far is: int main(void) { if (printf("Hello World!\n"), exit(0), true) { /* do nothing */ } } But I don't understand why I don't get compiler error (Visual Studio): error C4716: 'main' : must return a v...

Events in lambda expressions - C# compiler bug?

I was looking at using a lamba expression to allow events to be wired up in a strongly typed manner, but with a listener in the middle, e.g. given the following classes class Producer { public event EventHandler MyEvent; } class Consumer { public void MyHandler(object sender, EventArgs e) { /* ... */ } } class Listener { p...

weird C# compiler error: cyclic inheritance

I came across the following error a few days ago, in one of our C# applications here at work. Here's how the error message looks like: "Inherited interface '...ResourceManager.ResourcesManager' causes a cycle in the interface hierarchy of '...ResourceManager.IResourcesManagerView' in D:...\Common\ResourceManager\IResourcesManagerView.cs...

Error Compiling C++/CLI Delegate call

The following code results in C3867 (...function call missing argument list...) and C3350 (...a delegate constructor expects 2 argument(s)...). What am I doing wrong? public ref class Form1 : public System::Windows::Forms::Form { public: bool IsEven(int i){ return (i % 2) == 0; } Form1(void) { ...

I'm getting a C++ compiler error with the '<<' operator. Anyone know why?

I've been working on getting this program complete where it saves multiple structs to a file, can read them back and edit them, then save them all back to a file. I've been working on the logic of this not to mention lots of help from others and a ton of googling hours... now I am getting a compile error. Any help would be very appreciat...

MSVC++ compiler error C2143

The following code excerpt is responsible for a cryptic MSVC++ compiler error: template<class T> class Vec : public vector<T>{ public: Vec() : vector<T>(){} Vec(int s) : vector<T>(s){} T& operator[](int i){return at(i); } const T& operator[](int i)const{ return at(i);} }; ... The error: test.cpp(5) : error C2143:...

C2065 undeclared identifier while assigning a define to an int

Hi, I have a small problem with a define. I want to assign it to an integer variable but the compiler says it's undeclared. Here's what the code looks like: defines.h #ifndef DEFINES_H #define DEFINES_H #define MYDEFINE 2 #endif myclass.h namespace mynamespace { class myClass { int someFunction(); }; } myclass.cxx #include ...

Why compiler is not giving error when signed value is assigned to unsigned integer? - C++

I know unsigned int can't hold negative values. But the following code compiles without any errors/warnings. unsigned int a = -10; When I print the variable a, I get a wrong value printed. If unsigned variables can't hold signed values, why do compilers allow them to compile without giving any error/warning? Any thoughts? Edit Comp...

Is JS lint available for offline use?

I'd like to use JSLint but am wary of tools that have access to my unfiltered source-code. Is there an offline version or is there another similar tool that does "lint error checking" for JavaScript offline? Edit: One with a GUI / shows you a styled list of errors, instead of command line? ...

Type conflicts with ITSELF just because it's included as a return type of a web method in an ASP.NET web service?

I have an irritating problem, I'm creating an asp.net web service; this service should expose the functionality of an existing library, the service allows users to Upload files to our server by invoking the UploadFile method on the service. Here's the signature of the UploadFile method public bool UploadFile(string bucketName, string d...

Why does g++ complain when using templated typedefs in graph_traits<>?

When I try to compile this code: struct BasicVertexProperties { Vect3Df position; }; struct BasicEdgeProperties { }; template < typename VERTEXPROPERTIES, typename EDGEPROPERTIES > class Graph { typedef adjacency_list< setS, // disallow parallel edges vecS, // vertex container bidirectionalS, // directed graph property<verte...

Why C++ compiler (gcc) thinks function is `virtual' field?

I have a the following method definition in my class: virtual Calc* Compile( Evaluator* evaluator, ResolvedFunCall* fun_call, string* error); For some reason, GCC complains that: error: 'Compile' declared as a 'virtual' field Any ideas why it would believe Compile to be a field, instead of a method? ...

c2593 error (operator identifier is ambiguous) when compiling for x64 platform

I'm trying to compile a C++ project using Microsoft VisualStudio 2008. This particular project compiles fine if you use Win32 as target platform. If I try to compile the same project for the x64 platform I get a C2593 'operator identifier' is ambiguous error in this line: case 't': os_ << (size_t)path->rnode->char_type; break; An...

Why can't I assign a const value, and what should I do instead?

I have a piece of code with the following rough signature: void evaluate(object * this) { static const int briefList[] = { CONSTANT_A, CONSTANT_Z }; static const int fullList[] = { CONSTANT_A, CONSTANT_B, ..., CONSTANT_Z}; const int const * pArray; const int nElements; int i; if ( this->needDeepsEvaluation ) ...