I can initialize a List like new List{1,2,3,4,5};
However List does not have a constructor which accepts a single parameter.
So I tried to run this through the debugger and it seems to be calling the Add method.
So how does the compiler know which method to invoke to add each individual element.
This may be a silly question but I am a bit confused.
Thanks
Now I know that what can be computed or what cannot be computed?
So let me know about the undecidable problems in programming and compiler.How can we proof knowing something is impossible?
I want to calculate time elapsed during a function call in C, to the precision of 1 nanosecond.
Is there a timer function available in C to do it?
If yes please provide a sample code-snippet.
Pseudo code
Timer.Start()
foo();
Timer.Stop()
Display time elapsed in execution of foo()
Environment details: - using gcc 3.4 compiler on a RHEL machine
Hey,
I'm trying to use the Libxl library in my eclipse c/c++ project. Right now I'm using the minGW compiler in eclipse.
With this following code:
Book* book = xlCreateBook();
I get this error:
/src/xls2csv.cpp:22: undefined reference to `xlCreateBookCA'
Any help would be greatly appreciated :)
Class Test{
int value;
static void* thread_func(void* args){
value++;
}
void newthread(){
pthread_create(&thread_func,...);
}
}
I'm trying to create a thread in Class Test. Therefore compiler forces me to make thread_func static. However I cannot access the non-static member "value" anymore. It says:
invalid use of member 'Class::value' in static member function
Is there a way around it?
A classes Type metadata can be obtained in several ways. Two of them are:
var typeInfo = Type.GetType("MyClass")
and
var typeInfo = typeof(MyClass)
The advantage of the second way is that typos will be caught by the compiler, and the IDE can understand what I'm talking about (allowing features like refactoring to work without silently breaking the code)
Does there exist an equivalent way of strongly referencing members/properties/methods for metadata and reflection? Can I replace:
var propertyInfo = typeof(MyClass).GetProperty("MyProperty")
with something like:
var propertyInfo = property(MyClass.MyProperty)
I have a Qt application that I can compile in Ubuntu 10.04 64-bit and on Windows. However, I would like to avoid switching to Windows every time I want to compile the Windows version.
Is there a way I can compile a Windows Qt executable in Ubuntu with mingw32 or something?
Further, is there a way to integrate that compiler into Qt Creator?
I'm reading about how to put a makefile together, but no-one seems to mention what to do if your files require different sets of libraries, they all seem to use the same set of libraries for each file. Since it seems unlikely that every single file has the same libraries, I take it the list they use must amalgamate all of the libraries required across the project.
I just wanted to know if there's any downside to including too many libraries, or if the compiler works out which ones are needed and ignores the rest?
Thanks
The first definition below produces the warning in the title when compiled with f# 3.0 and the warning level set to 5. The second definition compiles cleanly. I wondered if someone could please explain just what the compiler worries I might accidentally mutate, or how would splitting the expression with a let clause help avoid that. Many thanks.
let ticks_with_warning () : int64 =
System.DateTime.Now.Ticks
let ticks_clean () : int64 =
let t = System.DateTime.Now
t.Ticks
I have trouble compiling a class, which has function pointers as member variables. The pointers are to functions which take an instance of a class as argument.
Like
template<class T, int N>
double (*f)(Vector<T,N> v);
I get "error: data member 'f' cannot be a member template" Compiler is gcc 4.2.
Many utilities of boost have been included as part of extended C++ TR1 currently.
Is the complete boost library going to be included once the standard is officially out ? In other words, do I need boost library, if I have complete standard conforming C++11 compiler ?
If not then any reason for that (Reliability cannot be an issue; as far as I know it's written by many people from standard committee) ?
Are tr1 headers available for g++ v3.4.6? If so, how can I locate them at compile time.
The following is failing to compile:
#include <tr1/memory>
With the following error:
myModule.h:20:24: tr1/memory: No such file or directory
Do I need to move to a later compiler or do I have the headers somewhere?
Is it generally valid that a macro is used to create a method name? I mean...actually it's just simple text replacement before the compiler actually runs, right?
This is my Javac compiling statement:
javac -cp "C:\java\code\j3D\j3dcore.jar;C:\java\code\j3D\j3dutils.jar;C:\java\code\j3D\vecmath.jar" Simple.java
compiles with no problems.
The three jar files (j3dcore, j3dutils, and vecmath) are the essential jar's for my program (or at least I am led to believe according to this official tutorial on J3D
For the record I ripped this code almost line from line from this pdf file.
jar files are correctly located in referenced locations
When I run my Simple program, (java Simple) I am greeted with
Exception in thread "main" java.lang.NoClassDefFoundError: javax/media/j3d/Cavas3d
Caused by: java.lang.ClassNotFoundExpection: javax.media.j3d.Canvas3D
Currently I am staring directly at this Canvas3D.class that is located within j3dcore.jar\javax\media\j3d\
wtfisthis.jpg
Here is the source code:
//First java3D Program
import java.applet.Applet;
import java.awt.BorderLayout;
import java.awt.Frame;
import java.awt.event.*;
import com.sun.j3d.utils.applet.MainFrame;
import com.sun.j3d.utils.universe.*;
import com.sun.j3d.utils.geometry.ColorCube;
import javax.media.j3d.*;
import javax.vecmath.*;
import java.awt.GraphicsConfiguration;
public class Simple extends Applet {
public Simple() {
setLayout(new BorderLayout());
GraphicsConfiguration config = SimpleUniverse.getPreferredConfiguration();
Canvas3D canvas3D = new Canvas3D(config);
add("Center", canvas3D);
BranchGroup scene = createSceneGraph();
scene.compile();
// SimpleUniverse is a Convenience Utility class
SimpleUniverse simpleU = new SimpleUniverse(canvas3D);
// This moves the ViewPlatform back a bit so the
// objects in the scene can be viewed.
simpleU.getViewingPlatform().setNominalViewingTransform();
simpleU.addBranchGraph(scene);
} // end of HelloJava3Da (constructor)
public BranchGroup createSceneGraph() {
// Create the root of the branch graph
BranchGroup objRoot = new BranchGroup();
// Create a simple shape leaf node, add it to the scene graph.
// ColorCube is a Convenience Utility class
objRoot.addChild(new ColorCube(0.4));
return objRoot;
}
public static void main(String args[]){
Simple world = new Simple();
}
}`
Did I import correctly?
Did I incorrectly reference my jar files in my Javac statement?
If I clearly see Canvas3D within its correct directory why cant java find it?
The first folder in both j3dcore.jar and vecmath.jar is "javax". Is the compiler getting confused?
If the compiler is getting confused how do I specify where to find that exact class when referencing it
within my source code?
lets say I have this
char *something[] = {
"/bi",
"-c",
"5",
NULL,
NULL
};
but I want to declare it in hex, how would I do this; compiler keeps erroring out on me:
char *something[] = {
{0x2f,0x62,0x69},
{0x2d,0x63},
{0x35},
{0x00},
{0x00}
};
In C#, I can write something like:
using (new MyDisposableClass().MethodA());
The semicolon causes a compiler warning to be shown which states possible mistaken empty statement. I haven't run the above code but won't the method still be called?
What uses is there of this type of coding convention? I saw another thread on here about this but I ask in case there areny differences now/therefore different replies.
Thanks
Why is it that I have to upgrade to VS 2010 to build/run .NET4 projects? This seems somewhat ridiculous to me. Why should the run-time that my code runs against, or the compiler that the IDE invokes (hopefully) generically through MSBUILD rules have anything to do with the IDE I am using?
1) Why are member constants available even if there are no instances of a its class?
2) Is the only reason why constant expressions need to be fully evaluated at compile time due to compiler replacing constant variable with literal value?
3) Since string is also an object, I would think the following would produce an error, but it doesn’t. Why?
class A
{
const string b = “it works”;
}
thank you
I've searched through the web and what I've found out is this:
To make the compiler warn you of the details of which methods you used that were deprecated use the javac.exe -deprecation switch. Then look in the Javadoc for the deprecated methods to find out the recommended replacements. Sometimes you just have to rename. Sometimes the replacements work quite differently.
But I'm not really understand how it works, can anybody help me with this?
I have the following text in my MXLM sample:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"
xmlns:ns1="com.infrared5.asmf.controls.flex.data.*"
xmlns:ns2="com.infrared5.asmf.controls.flex.video.*"
xmlns:ns3="com.infrared5.asmf.controls.flex.net.*"
xmlns:ns4="jedai.controls.flex.data.*"
xmlns:ns5="jedai.controls.flex.video.*"
xmlns:ns6="jedai.controls.flex.net.*">
Last 6 namespaces are defined as some "dotted" name pathes. Where does compiler look for them and in which order?
I do not understand the documentation for gprof regarding how to compile your program for profiling with gprof. In g++, is it required to compile with the -g option (debugging information) in a addition to the -pg option or not. In each case I get different results, and I would like to see where the bottlenecks in my application are in release mode, not in debug mode, where many optimizations are left out by the compiler (e.g. inlining)
does the Destructor deallocate memory assigned to the object which it belongs to or is it just called so that it can perform some last minute housekeeping before the object os deallocated by the compiler?