compilation

How does java compiler choose correct methods and variables in inheritance

微笑、不失礼 提交于 2019-12-02 15:01:16
问题 I am a bit confused when inheritance and type casting is mixed. I want to understand the rules which java compiler follows when choosing correct methods and variables in inheritance. I have read something like Variables are bound at compile time and methods are bound at run time. The second one is from stackoverflow (@John Skeet) Overload resolution (which method signature is called) is determined at compile-time, based on the compile-time types of both the method target and the argument

Compiling java 7 for java 6 with Eclipse

别说谁变了你拦得住时间么 提交于 2019-12-02 14:58:23
问题 I need to compile a project for Java 6 to use with java 6 or 7 (I can't upgrade all of the computers in my life). I've been searching all over and found somewhat helpful stuff, but I'm rather new to java - I don't understand much of how to use the presented alternatives (ant-build, Maven, javac). My program does not use any API methods that are not available in Java 6, but it does use the API of another external .JAR (it is a basic plugin for an example program) Is there a simple way to do

What should I change to make this file compile?

老子叫甜甜 提交于 2019-12-02 14:53:15
I am in a programming class and this program is part of my homework. This file analyzes data from a file called "Names.txt" and then prints the information. I'm getting compilation errors and I want to know what I need to change or add to make it compile successfully. Here is my code: import java.util.Scanner; import java.io.File; import java.io.FileNotFoundException; public class NameApp { public static void main(String[] args) { Scanner stdin = new Scanner(System.in); String selection, nameIn, nameIn2; Name name, name2; int decade; String first = "1", second = "2", third = "3", fourth = "4",

How to fix error with xml2-config not found when installing PHP from sources?

五迷三道 提交于 2019-12-02 14:45:50
When I try to install php 5.3 stable from source on Ubuntu (downloading compressed installation file from http://www.php.net/downloads.php ) and I run ./configure I get this error: configure: error: xml2-config not found. Please check your libxml2 installation. TroodoN-Mike All you need to do instal install package libxml2-dev for example: sudo apt-get install libxml2-dev On CentOS/RHEL: sudo yum install libxml2-devel For the latest versions it is needed to install libxml++2.6-dev like that: apt-get install libxml++2.6-dev I had the same issue when I used a DockerFile. My Docker is based on

Given the state of the stack and registers, can we predict the outcome of printf's undefined behavior

孤者浪人 提交于 2019-12-02 13:44:57
Here is some simple C code for a class quiz: #include <stdio.h> int main() { float a = 2.3; printf("%d\n", a); return 0; } Compiled and run on: Apple LLVM version 6.1.0 ( clang-602.0.53 ) (based on LLVM 3.6.0svn) Target: x86_64 -apple-darwin14.5.0 The output of this code is undefined . I am trying to predict the output by inspecting the memory near a with the debugger ( X command in gdb). For example, when the address of a is 0x7fff5fbffb98 , then the context near &a is as follows: 0x7fff5fbffb98: 1075000115 0x7fff5fbffb9c: 0 0x7fff5fbffba0: 1606417336 0x7fff5fbffba4: 32767 0x7fff5fbffba8:

Build Python (2.7) module on GCC 4.8 fails

不打扰是莪最后的温柔 提交于 2019-12-02 13:34:35
I'm trying to build a Python Module/extension write using C API, but it fails: % python2 cmath.py build running build running build_ext building 'c_math' extension creating build creating build/temp.linux-x86_64-2.7 gcc -pthread -fno-strict-aliasing -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector --param=ssp-buffer-size=4 -D_FORTIFY_SOURCE=2 -DNDEBUG -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector --param=ssp-buffer-size=4 -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/python2.7 -c c_math.c -o build/temp.linux-x86_64-2.7/c_math.o c_math.c:18:5: warning: initialization from

Java: Cannot find symbol? [duplicate]

女生的网名这么多〃 提交于 2019-12-02 12:54:27
This question already has an answer here: What does a “Cannot find symbol” or “Cannot resolve symbol” error mean? 13 answers When I try to compile a small program I wrote that builds an array of a deck of cards and prints them, I get 6 errors all of which are "cannot find symbol" errors. Can somebody check my code and find the mistakes please? Thanks. Compile Output: sudhakar@sudhakar-Dell-DXP061 ~/deck $ javac doDeck.java Deck.java Card.java doDeck.java:7: cannot find symbol symbol : variable deck location: class carddeck.Deck System.out.println(mydeck.deck[x].getRankString() + " of " +

Unroll loop at compile time

旧城冷巷雨未停 提交于 2019-12-02 12:09:57
问题 I want to write a load of lines into a C++ file of the form foo(i) for i = 0,1, ... , n , is there a way of doing this at compile time? I want to do this because I've got a templated class: template <int X> class MyClass{ ... } and I want to test it for lots of different values of "X" with something like: for (int i = 0; i < n; i++) { MyClass<i> bar; bar.method() } This doesn't work as it wants the value passed as the template value to be determined at compile time. I could write out the

Compiling java 7 for java 6 with Eclipse

非 Y 不嫁゛ 提交于 2019-12-02 12:06:09
I need to compile a project for Java 6 to use with java 6 or 7 (I can't upgrade all of the computers in my life). I've been searching all over and found somewhat helpful stuff , but I'm rather new to java - I don't understand much of how to use the presented alternatives (ant-build, Maven, javac). My program does not use any API methods that are not available in Java 6, but it does use the API of another external .JAR (it is a basic plugin for an example program) Is there a simple way to do this with Eclipse's Export function, or do I need to use some other program/method? If I need to use

How to make a makefile only for compiling some java files?

荒凉一梦 提交于 2019-12-02 11:52:38
I have three java files named A.java, B.java, C.java, A will create object B, B will create object C. But I have never built a makefile before. Does anyone can help me build a makefile just to compile these three java files? And what tool should I use to make a makefile? Thank you! rgettman Define your suffixes. Define how to turn .java into .class Define what classes you want Define an "all" target. You don't need any specific editor for making a makefile; even Notepad would do. 来源: https://stackoverflow.com/questions/15169634/how-to-make-a-makefile-only-for-compiling-some-java-files