compilation-errors

Conditional compilation symbols not being defined

Hello, I am having trouble getting Visual Studio to behave as I would expect it. I created 2 configuration profiles. One has the symbol FOO defined and the other has the symbol BAR defined. And I have this code: static class MyClass{ #if FOO public static string const MyData="foo defined"; #endif #if BAR /*yes, I know #elif would work...

bool operator() and inheritance

I have the following problem with bool operator() for derived class Base class class Point { double x, y; public: Point(){x=0;y=0;} ... } Derived class class 3DPoint : public Point { double z; public: 3DPoint(double x, double y, double zx) : Point(x,y){z(zz);} ... } operator () for derived class class compareByX { bool operator (...

Error compiling BASIC "libnotify" code...

#include <libnotify/notify.h> #include <glib.h> #include <unistd.h> int main(int argc, char** argv) { if(argc == 3) { NotifyNotification *n; notify_init("Test"); n = notify_notification_new (argv[1],argv[2], NULL, NULL); notify_notification_set_timeout (n, 3000); //3 seconds if (!notify_not...

Error in compiling C++ code?

This is my test.cpp: #include <iostream.h> class C { public: C(); ~C(); }; int main() { C obj; return 0; } When I compile it using the command g++ test.cpp, I get this error message: In file included from /usr/lib/gcc/i686-pc-cygwin/3.4.4/include/c++/backward/iostream.h:31, from test.cpp:1: /usr/lib/gcc...

Getting confused in with == and = in "if" statement

I know that we cant use assignment operator in if statements in java as we use in any other few languages. that is int a; if(a = 1) { } will give a compilation error. but the following code works fine, how? boolean b; if(b = true) { } EDIT : Is this the exception to rule that a...

ASP.NET MVC and Strings doesn't give me compile time errors.

I'm a big fan of compilation errors. I find the a lot easier to fix than runtime bugs. I currently using the ASP.NET MVC framework and I find it has a lot of room for typos that the compiler won't catch. For Example if I want to return the view Data from the Index action. public ActionResult Index() { return View("Data"); } can...

"code too large" compilation error in java

Hello all, Is there any maximum size for code in java.. i wrote a function with more than 10,000 lines. Actually , each line assigns a value to an array variable.. arts_bag[10792]="newyorkartworld"; arts_bag[10793]="leningradschool"; arts_bag[10794]="mailart"; arts_bag[10795]="artspan"; arts_bag...

LockWorkStation - Compilation error - identifier not found

Hi All, I am writing an application in which I got to lock the computer screen (OS is Windows). My Application is in C++. For this purpose I used the LockWorkStation() API defined on msdn, http://msdn.microsoft.com/en-us/library/aa376875%28VS.85%29.aspx I have included windows.h as told but still I am getting compilation error: .\sour...

VC6 compilation error

Hi there are some vs2005 c++ files in PJNSMTPCONNECTION Classes, but my application is in vc6, now can any one tell whether CSTRINGA, CSTRINGW are available in vc6.. if not how overcome this problem ...

C++ reference variables

I have these two functions (with Point2D & LineVector (has 2 Point2D member variables) classes and SQUARE macro predefined) inline float distance(const Point2D &p1,const Point2D &p2) { return sqrt(SQUARE(p2.getX()-p1.getX())+SQUARE(p2.getY()-p1.getY())); } inline float maxDistance(const LineVector &lv1,const LineVector &lv2) { ...

c++ compilation error

hello, i got a compile error which i do not understand. i have a h/cpp file combination that does not contain a class but just defines some utility functions. when i try to use a struct that is defined in another class i get the error: error C2027: use of undefined type 'B::C' so, stripped down to the problem, the h-file looks like thi...

Generics compiles and runs in Eclipse, but doesn't compile in javac

Note: This is a spin-off from Comparable and Comparator contract with regards to null This code compiles and runs fine in Eclipse (20090920-1017) import java.util.*; public class SortNull { static <T extends Comparable<? super T>> Comparator<T> nullComparableComparator() { return new Comparator<T>() { @Override...

Java Switch Incompatible Types Boolean Int

I have the following class: public class NewGameContract { public boolean HomeNewGame = false; public boolean AwayNewGame = false; public boolean GameContract(){ if (HomeNewGame && AwayNewGame){ return true; } else { return false; } } } When I try to use it like so: if (networkConnection){ ...

Protecting one class from the bad programming of another?

Is there a way in PHP to try to include a file, but if the file contains errors that stop it from compiling to just skip that file from inclusion? ...

NVIDIA CUDA SDK Examples Compilation Unsupported Architecture 'compute_20'

On compilation of the CUDA SDK, I'm getting a nvcc fatal : Unsupported gpu architecture 'compute_20' My toolkit is 2.3 and on a shared system (i.e cant really upgrade) and the driver version is also 2.3, running on 4 Tesla C1060s If it helps, the problem is being called in radixsort. It appears that a few people online have had this ...

Mixed calling conventions make compilation errors

Hi, I have a library (C++) which has some API functions. One of them is declared as __cdecl, but gets a function poiner from __stdcall. Something like: typedef int (__stdcall *Func)(unsigned char* buffer); //... int ApiFunc(Func funcPtr); //This is __cdecl since it is an 'extern "C"' library and the calling convention is not specified...

CString 'Trim' : is not a member ,why?

Hello all i have simple app that i try to compile with VC express and using the : microsoft platform sdk for windows server 2003 that contains mfc and atl now i have this simple code : CString strValue("test"); CString s = strValue.Trim(); LPCTSTR lpStr = (LPCTSTR)strValue.Trim() that give me compilation error : c:\dev\test.cpp(463) ...

Using generics with wildcards does not allow using methods with generic as a parameter

If i declare a generic class as something like public class Driver<V extends Car> where Car is an interface. Then, I use it with something like this: Driver<?> driver = new Driver<Chevrolet>(); I don't want to specify a specific implementation of car as the generic. Why is it that I cannot call methods implemented in driver that ...

Java non-static method addInv(int) cannot be referenced from a static context

I know this error very well however this is the once time I'm stumped. I know that I can't call non-static variables from main method but this is confusing. Maybe you can help? That error is show on addInv(1); line... Code: import java.io.*; import java.util.*; import javax.swing.*; public class item { public static int attack, de...

Passing ExecContext<?> to a method when you don't know the type

How can I pass a generic type to a method, when I don't know the type? public static class ExecContext<E> { public void doSomething(E e) { System.out.println(e); } } public static void exec(ExecContext<?> ctx) { String s = new String("saoj"); ctx.doSomething(s); // <============== COMPILE ERROR } ...