compiler-errors

How come the compiler thinks this variable isn't constant?

旧城冷巷雨未停 提交于 2021-02-08 01:58:12
问题 This is my code: int main() { const int LEN = 5; int x[LEN]; } VS10 says: error C2057: expected constant expression error C2466: cannot allocate an array of constant size 0 error C2133: 'x' : unknown size I even tried the the code in this page and it gives the same problem (I commented the code which gives the error, and uncommented the correct one): http://msdn.microsoft.com/en-us/library/eff825eh%28VS.71%29.aspx If I was trying a crappy compiler, I would think it's a bug in the compiler,

Why does Java compiler refuse to recognize System.exit() as a procedure termination?

你。 提交于 2021-02-07 16:24:30
问题 Java's compiler, at least the one from Oracle that I use, refuses to recognize System.exit() as a procedure termination. For example, the following code gives a compilation error: public static int readInteger( ArrayList<String> listLines, int iLineNumber0 ){ try { int value = Integer.parseInt( listLines.get( 0 ) ); return value; } catch( Throwable t ) { System.err.println( "error reading line: " + iLineNumber0 + ": " + t ); System.exit( -1 ); } } The error is: "Missing return statement."

How to compile and run kotlin program in command line with external java library

笑着哭i 提交于 2021-02-07 14:50:32
问题 I am trying kotlin for the first time. I was able to run compile the hello world program in kotlin on command line but I am not able to compile program where I want to include external java library import com.google.gson.Gson data class Person(val name: String, val age: Int, val gender: String?) fun main(args: Array<String>) { println("Hello world"); val gson = Gson() val person = Person("navin", 30, null) val personJson = gson.toJson(person) println(personJson) } Directory structure ➜ kotlin

How to compile and run kotlin program in command line with external java library

馋奶兔 提交于 2021-02-07 14:48:59
问题 I am trying kotlin for the first time. I was able to run compile the hello world program in kotlin on command line but I am not able to compile program where I want to include external java library import com.google.gson.Gson data class Person(val name: String, val age: Int, val gender: String?) fun main(args: Array<String>) { println("Hello world"); val gson = Gson() val person = Person("navin", 30, null) val personJson = gson.toJson(person) println(personJson) } Directory structure ➜ kotlin

Java cooperating generic classes: can we avoid unchecked cast?

浪尽此生 提交于 2021-02-07 11:13:33
问题 Edit: Sorry; eager to give you a minimal example, I didn’t provide enough information about the requirements in my first version of this question. I have two abstract generic classes. They cooperate and hence depend on each other. Occasionally one needs to pass this to the other. I am trying to find a type safe way to do this. public abstract class AbstractA<T extends AbstractB<? extends AbstractA<T>>> { protected void foo() { T aB = createB(); aB.setA(this); } /** factory method */ abstract

How Can I Solve this Crash when Compiling an iOS App with OpenCV Contrib using React Native?

故事扮演 提交于 2021-02-07 11:04:14
问题 trying to compile an iOS app with OpenCV 4.3 with contrib in a react native app. The app works fine in xcode, but as soon as I try compiling to bit code, the app fails. I've gone through several similar questions, but have not had any results and I'm hoping someone more experienced than I might have some suggestions. The .ipa file does generate and I can test it on an iPad or iPhone, but as soon as the app opens, it crashes. Here is the crash log; {"app_name":"helloOpenCV","timestamp":"2020

Android Lint erroneously thinks min SDK version is 1

自作多情 提交于 2021-02-05 19:57:55
问题 Eclipse refuses to build my Android project. In the package explorer, the project root node has the little red error symbol, but nothing else inside of it has this symbol. The Problems tab shows errors detected by Lint: Call requires API level 3 (current min is 1): android.os.AsyncTask#<init> Call requires API level 3 (current min is 1): android.view.GestureDetector#<init> Call requires API level 3 (current min is 1): android.view.inputmethod.InputMethodManager#hideSoftInputFromWindow Call

“no suitable method found for between(Date, Date)" when trying to calculate difference in days between two dates

99封情书 提交于 2021-02-05 12:32:15
问题 How to calculate the difference between current day and date of the object that user had previously selected from jXDatePicker swing component and that had been added as Date to that object. In my current code at the last line I'm getting this error message: no suitable method found for between(Date, Date) Date currentDate = new Date(); Date objDate = obj.getSelectedDate(); //getting date the user had //previously selected and that been //added to object long daysDifference = ChronoUnit.DAYS

Link mat.h in a C++ file

依然范特西╮ 提交于 2021-02-05 09:20:50
问题 I have to use mat.h for open a .mat file in my C++ code. My code is that: #include "mat.h" using namespace std; int main() { MATFile *pmat; pmat = matOpen("ns3Da.mat","r"); return 0; } The command I use to compile is that: g++ program.cpp -I/usr/local/MATLAB/R2012a/extern/include -L/usr/local/MATLAB/R2012a/bin/* -L/usr/local/MATLAB/R2012a/extern/lib -o program The error I obtain is that: /tmp/ccSWqTnb.o: In function 'main': programma_c.cpp:(.text+0x13): undefined reference to 'matOpen'

how to define a 2d array using malloc and pass it to a function

[亡魂溺海] 提交于 2021-02-05 09:13:55
问题 I want to pass a 2d array i defined using malloc to a function. First i define the array using code from a blog post. int** Make2DIntArray(int arraySizeX, int arraySizeY) { int** theArray; theArray = (int**) malloc(arraySizeX*sizeof(int*)); for (int i = 0; i < arraySizeX; i++) theArray[i] = (int*) malloc(arraySizeY*sizeof(int)); return theArray; } int main(){ int** myArray = Make2DIntArray(nx, ny); } I can then use it as myArray[i][j]. After that,i want to pass this array to a function.I