How to fix Eclipse CDT error "function" isdigit "cannot be solved" with Android NDK?

I am using Eclipse Indigo with a mixed Android / NDK project. I added the nature of C ++ and almost everything works. Automatic assembly of work; that is, when I edit the file, ndk-build is called and succeeds - no build errors. Working with a code mouse assistant (a small window appears with information about the function). If I put the cursor on the power line and press F3, the corresponding header file will open (not the one I would expect based on my configuration, but the corresponding one - maybe the key?).

If I select the following line in my .cpp file, it opens $ NDKROOT / platform / android-3 / arch-arm / usr / include / ctype.h:

#include <ctype.h> 

(isdigit is defined in this file)

However, Eclipse insists that isdigit is undefined. I read a lot of posts about blaming a static analyzer or indexer, but I tried many of the suggested solutions to no avail.

If I add a line as shown below, the error will disappear and the helper code to support the function works:

 extern int isdigit(int); 

Again, this is not a linker error or a compiler error - ndk-build exits without errors. This is something inside an eclipse. Thanks for watching!

Edit: Now I believe this is a problem with code analysis. The best solution is to edit the code analysis parameters so that the “function could not be enabled” instead of a warning is a warning. Thus, you can see warnings in the Problems view, but continue to work. If the function is REALLY missing, the compiler will tell you! I also have a new theory that the problem lies in the Code Analyzer after symbolic links, because all the "missing" functions are contained in files with symbolic inclusions. I would like to love any contribution to this theory.

+6
source share
5 answers

I worked on this issue with the approach I suggested in my question, and still could not find a better way.

+2
source

After several days of working on such problems, I developed the following recipe to solve the problem.

Hope this helps you or others:

Summary. Typically, problems in eclipse are related to eclipse configuration problems. The following assumes your C ++ code is working with ndk_build or ndk_build.cmd (on windows).

  • There is no joy in eclipse juno (4.2) and CDT version 8.1. Use eclipse indigo (3.7)

  • Ensure that the indigo CDT is installed and enabled (version 8.0X) by viewing "Install New Software." By default, it is installed, but not enabled on indigo on some downloads.

  • When dealing with native code or Android configuration for native code, make sure that you are in the C ++ / C perspective in eclipse and not in java. This is misleading, but there is only a subset of the options available in Java. You can be sure that you are a C ++ / C perspective if you see "C / C ++ general" as a choice when you execute "Project> Properties".

  • A common problem is that the indexer in C / C ++ - the earth thinks that there are errors when not (for example, creating with ndk-build works fine, often you can even see this in the console window). This is caused by incorrect paths in the "Paths And Symbols" section of "Project> Properties> C / C ++ General" on the first tab.

  • To fix the problem, the main tool is a right-click on the project, select "Index" and "Search for unauthorized inclusions." This will tell which files he cannot find - and usually these are not the ones you have in your files with a little pink label.

  • To find the file you need, search the NDKROOT directory (where you installed NDK). Typical additions are: ${NDKROOT}/platforms/android-9/arch-arm/usr/include or the right android-N for your Android target. There are many copies of the standard, including directories in the NDK due to several versions of android and copies of the standard C ++ libraries.

Two big warnings

  • "Unauthorized included" views in eclipse are not automatically updated when the indexer configuration is changed in the properties> General / Paths and C / C ++ settings, so be sure to run them every time. Most eclipse views do this update correctly!

  • Also, small red / pink error markers in source views in the eclipse editor are also not updated automatically. You must “touch” the file in some way to find that the error has been fixed.

+5
source

Perhaps this will help:

  • Go to Project> Properties
  • Go to C / C ++ Build> Settings
  • Go to GCC C Linker> Miscellaneous Settings
  • Add the following to the linker flags: -lc
+2
source

Have you tried rebuilding the indexer? (right-click project in explorer index-> ​​rebuild project) Sometimes this fixes the problem ... If you updated the previous version of eclipse, your installation of the indexer may be a problem - you can try to restore the indexer settings (c / C ++ preferences Indexer) ... I hope this helps - this question may be "insane" (it seems to happen often)

0
source

I had the same problem with Linux with different toolchains. Even the simplest C ++ code (for example, the one created by the welcome masters) will have syntax errors, without a layout problem. As another Thorbjorn Jemander post indicated, the problem is with the indexer and can be fixed by unchecking the option “Enable heuristic replication of inclusions”. Explicitly: Winsow → Settings → C / C ++ → Indexer → deselect the above option.

After that, you can see that the highlighted errors disappear after you open the file in the editor and just click on the editor page ...

0
source

Source: https://habr.com/ru/post/916671/


All Articles