Please note: The issue I’m about to describe does not get replicated while I use the “simple” Arduino IDE.
Issue: I get ‘Unknown type name’ error for a variable I’m using even though I’ve included the appropriate library. The library is “Adafruit MPR121.”
Code:
#include "Adafruit_MPR121.h" //this line references the library needed for the touch IC breakout.
Adafruit_MPR121 cap = Adafruit_MPR121 (); //assigning variable for the touch sensor
Error message:
Unknown type name 'Adafruit_MPR121’clang(unknown_typename)
Older Version:
Hello,
Thank you for reading this.
Please note: The issue I’m about to describe does not get replicated while I use the “simple” Arduino IDE.
Issue: I get ‘Unknown type name’ error for a variable I’m using even though I’ve included the appropriate library. The library is “Adafruit MPR121.”
As far as I can see, the Pro IDE uses a different compiler than the IDE. So this might be a compiler related issue.
A google search for clang(unknown_typename) shows similar errors and gives some possible workarounds; not sure if they will work for this specific issue.
It's possible to get this type of error when there are multiple libraries containing the files that match an #include directive and the IDE picks a different library than you intended. You might say that it's unlikely two libraries will contain such a specific filename as Adafruit_MPR121.h, but it happens.
Please do this:
Sketch > Verify/Compile
After the compilation finishes, click the Arduino Pro IDE's output pane.
Press Ctrl + A to select all the output (and everything else in the Pro IDE window unfortunately).
Press Ctrl + C to copy the selected text to the clipboard
Open a text editor.
Press "Ctrl + V". This will paste the copied text into the text editor.
Save the file somewhere convenient.
In this forum thread, click the "Reply" button.
Click the "Attachments and other options" link. Normally I recommend people always post output directly to the forum thread when possible, but I think it's very unlikely the Arduino Pro IDE's output will ever be under the forum's 9000 character limit, so I won't even bother with that.
Click the "Choose Files" button.
Select the text file you saved.
Click the "Open" button. The text file containing the output will now be attached to the forum thread reply.
Add a bit of text to the reply to satisfy the requirement that every reply contains text and then click the "Post' button.
Although I do recommend using the support form @sterretje recommended for reporting problems with the Arduino website and its content (other than Arduino Language Reference), when it comes to reporting software bugs you will likely get better results by reporting issues to the issue tracker of the project's repository, in this case:
The reason is this will bring the issue immediately to the attention of the developers of that project, rather than needing to work its way through several levels from the support staff (who don't have any ability to fix bugs). For administrative reasons too boring to talk about even if I was allowed to, this is even more the case for the Arduino Pro IDE
The situation is different with the Arduino website because none of that code/content is hosted in public repositories (with the exception of the Arduino Language Reference), so there is no directly relevant GitHub issue tracker to report to.
OK, so I can see from the output that the correct library is being used and your code is compiling, so this is a problem with what I believe is called the "language server" (the Pro IDE's version of Intellisense), which is supposed to identify problems in your code. This doesn't happen for me with a minimal sketch that contains the lines of code you shared.
If you restart the Pro IDE, does the problem still occur?
If so, please post your full sketch. It may be that some later code in your sketch is somehow breaking the language server.
OK, the problem was not related to anything in your sketch, but using your sketch allowed me to reproduce the problem purely by chance. It turns out that the issue only occurs when the sketch is saved to a location outside your user directory/sketchbook. When I was trying to reproduce the issue earlier, I was using a sketch inside my user directory, and so the language server was working fine. When I downloaded your sketch, it happened to be outside my user directory, and so the problem occurred.
So the workaround is to move your sketch to your user directory (/Users/ariankolahi-sohrabi/Documents/Arduino in this case). It can be in a subdirectory, but it just needs to be somewhere under that location.
I have submitted a bug report:
Thanks for bringing this issue to our attention @ArianKS! I think it's important for the Pro IDE to provide full support for sketches in any location.
I think there's a good chance it's something like that.
The truth is that I don't have very much experience with the Arduino Pro IDE (though I do have a lot of experience with Arduino CLI, which handles all the Arduino-specific stuff for the Pro IDE under the hood via a gRPC server). I tend to mirror what the forum users are doing, and so far there hasn't been a lot of posts about the Pro IDE on the forum. I'm sure we'll start seeing it more here as time goes on and it reaches a production release.
pert:
OK, the problem was not related to anything in your sketch, but using your sketch allowed me to reproduce the problem purely by chance. It turns out that the issue only occurs when the sketch is saved to a location outside your user directory/sketchbook. When I was trying to reproduce the issue earlier, I was using a sketch inside my user directory, and so the language server was working fine. When I downloaded your sketch, it happened to be outside my user directory, and so the problem occurred.
So the workaround is to move your sketch to your user directory (/Users/ariankolahi-sohrabi/Documents/Arduino in this case). It can be in a subdirectory, but it just needs to be somewhere under that location.
Using library SD at version 1.2.3 in folder: /Applications/Arduino.app/Contents/Java/libraries/SD
I can see that the SD library is located in your classic Arduino IDE installation. Although the Pro IDE's compilation system has no problem with that, the language server can't deal. So the solution is to use Library Manager to install the SD library, which will put a copy of it in your user directory:
Tools > Manage Libraries...
In the "Filter your search..." field, type "sd".
Press Enter.
Scroll down through the list of results until you see "SD by Arduino, SparkFun". If it doesn't show up, just keep trying various searches and restarting the Pro IDE over and over again until by some miracle it does show up in the search results (something seems to be very broken with the Pro IDE's Library Manager).
Hover the mouse pointer over "SD by Arduino, SparkFun".
Click the "Install" button.
Restart the Pro IDE (the language server doesn't update after installing the library).
Using library SD at version 1.2.3 in folder: /Applications/Arduino.app/Contents/Java/libraries/SD
I can see that the SD library is located in your classic Arduino IDE installation. Although the Pro IDE’s compilation system has no problem with that, the language server can’t deal. So the solution is to use Library Manager to install the SD library, which will put a copy of it in your user directory:
Tools > Manage Libraries…
In the “Filter your search…” field, type “sd”.
Press Enter.
Scroll down through the list of results until you see “SD by Arduino, SparkFun”. If it doesn’t show up, just keep trying various searches and restarting the Pro IDE over and over again until by some miracle it does show up in the search results (something seems to be very broken with the Pro IDE’s Library Manager).
Hover the mouse pointer over “SD by Arduino, SparkFun”.
Click the “Install” button.
Restart the Pro IDE (the language server doesn’t update after installing the library).
Thank you for the reply! I’ve searched for the SD library in the manager and have restarted the app 5 times or so now—but the library doesn’t show up. Is there a way I can “manually” copy/ move the SD library folder to the correct location?