An error that is generated during the compilation phase, often due to problems with invalid syntax and/or types. Compare to [runtime-error].
151
votes
21answers
219k views
The located assembly's manifest definition does not match the assembly reference
I am trying to run some unit tests in a C# Windows Forms application (Visual Studio 2005) and I get the following error:
System.IO.FileLoadException: Could not load file or assembly 'Utility, ...
136
votes
7answers
4k views
Why can I pass 1 as a short, but not the int variable i?
Why does the first and second Write work but not the last? Is there a way I can allow all 3 of them and detect if it was 1, (int)1 or i passed in? And really why is one allowed but the last? The ...
97
votes
3answers
2k views
Why does the C# compiler not fault code where a static method calls an instance method?
The following code has a static method, Foo(), calling an instance method, Bar():
public sealed class Example
{
int count;
public static void Foo( dynamic x )
{
Bar(x);
}
...
70
votes
11answers
14k views
GCC compile error with >2 GB of code
I have a huge number of functions totaling around 2.8 GB of object code (unfortunately there's no way around, scientific computing ...)
When I try to link them, I get (expected) relocation ...
57
votes
3answers
2k views
Why does gcc allow arguments to be passed to a function defined to be with no arguments?
I don't get why does this code compile?
#include <stdio.h>
void foo() {
printf("Hello\n");
}
int main() {
const char *str = "bar";
foo(str);
return 0;
}
gcc doesn't even ...
55
votes
3answers
20k views
Xcode - configure: error: no acceptable C compiler found in $PATH
rebuilding a mac from scratch. Installed xcode and rvm then trying to install rubies but they are all giving me:
Error running ' ./configure --prefix=/Users/durrantm/.rvm/rubies/ruby-1.9.3-p125
...
55
votes
4answers
1k views
Why does the C# compiler allow an explicit cast between IEnumerable<T> and TAlmostAnything?
The following code gives you a compiler error, as you'd expect:
List<Banana> aBunchOfBananas = new List<Banana>();
Banana justOneBanana = (Banana)aBunchOfBananas;
However, when using ...
52
votes
3answers
1k views
How can Eclipse create a class with unresolved compilation problems?
When I try to compile this class with javac, I get a compilation error and Test.class is not created.
public class Test {
public static void main(String[] args) {
int x = 1L; // <- ...
51
votes
3answers
2k views
Named arguments and generic type inference in C# 4.0
I had been programming under the assumption that, when calling a method in C# 4.0, supplying names for your arguments would not affect the outcome unless in doing so you were "skipping" one or more ...
46
votes
4answers
22k views
Resolve circular dependencies in c++
I often find myself in a situation where I am facing multiple compilation/linker errors in a C++ project due to some bad design decisions (made by someone else :) ) which lead to circular dependencies ...
42
votes
7answers
13k views
XCode 4.1 fatal error: stdlib modified since the precompiled header was built
Building an iPhone app, using:
XCode 4.1
Base SDK iOS 4.3
Apple LLVM Compiler 2.1
I have started getting the following error:
fatal error: file
...
42
votes
6answers
33k views
Anonymous method in Invoke call
Having a bit of trouble with the syntax where we want to call a delegate anonymously within a Control.Invoke.
We have tried a number of different approaches, all to no avail.
For example:
...
42
votes
15answers
9k views
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
37
votes
6answers
5k views
List<int> test = {1, 2, 3} - is it a feature or a bug?
As you know, it is not allowed to use the Array-initialisation syntax with Lists. It will give a compile-time error. Example:
List<int> test = { 1, 2, 3}
// At compilation the following error ...
36
votes
6answers
1k views
Why is an assignment to a base class valid, but an assignment to a derived class a compilation error?
This was an interview question. Consider the following:
struct A {};
struct B : A {};
A a;
B b;
a = b;
b = a;
Why does b = a; throw an error, while a = b; is perfectly fine?