Serious Noob Questions

I’ve been a developer for a long time, but have really only worked in C#, VB.net and supporting technologies, so C++ / Arduino is a whole new world for me and after a couple of days poking at it, I’m super frustrated.

I’ve seen some threads about the Arduino IDE being garbage, and I agree insofar as being able to understand references and method calls in other files.

I’m working on a Mac, and currently that’s the only machine I have access to. I’m really at a loss for how to set up the environment so that a new file can be seen by the old files. Is there anything like Arduino 101? A tutorial, articles or video that explains how to set up a new plugin? I’d like to just get a basic understanding of the file structure and how the .h file interacts with the .ccp file, how to consume or include that in the firmware…BASIC stuff.

Any assistance is greatly appreciated.

1 Like

To make things easy, I’d set up an environment to compile the factory firmware first. The wiki has a Getting Starded section, which should help you with that.

Once you can compile the factory firmware, you can put .cpp and .h files in the same directory, and Arduino will see that. Once you’re ready to move it to a proper plugin, independent of your working firmware sketch, post here again, and I’ll try to show how to do it in a few easy steps.

I’m able to compile the factory firmware and push an update to the board. But that’s without changing anything. If I try to open any of the files from the git package, I get an error saying that Arduino can’t open them. That’s why I feel like I need to really start at the beginning and understand the relationships between the files and what I can and cannot do.

Sounds like what you really need is a C++ starter guide first, before getting into Arduino. One that targets the command line not visual studio, so you can understand how compiling and linking works. (At the risk of sounding pompous, may I suggest investing time in learning C++ for the benefit of your career? It’ll help you understand what’s going on behind the scenes in C#, which becomes a must if you want to progress past a certain point.)

To get you started with headers, the mechanism is basically that whenever there’s an #include file.h directive in the code, the whole contents of file.h are copy-pasted at the beginning of compilation at the location of the include statement. (There are “include guards” [#pragma once, or #ifndef …] to prevent that happening multiple times.)

Typically .cpp files #include directly or indirectly (one .h can include another .h) all .h files for the symbols declarations (classes, methods, etc) they need. They trust that the symbol definitions (class and method bodies) will actually be available at the linking step, i.e. that all necessary .cpp files have been passed as argument to the compiler, producing object files that then get linked together into an executable or dll.

Forward declarations complicate things a bit, but that’s the system in a nutshell. Just look up the terms I didn’t expand on.