Question about the Arduino/libraries file structure

rodrigomorales:
I've read in stackoverflow that some developers complained about Arduino IDE

I've found that frequently when you see some experienced developer complaining about Arduino they actually have no clue what they're talking about because either their entire knowledge of of Arduino is based on other "developers" complaining about it or they spent five minutes looking at it back in 2011. I advise you to be skeptical of information that comes from people who don't actually have any experience with Arduino.

rodrigomorales:
adding code on the background, to ease work of developers.

Actually the purpose of Arduino is to make it easy for beginners, who may have little or no prior experience in programming and electronics to use microcontrollers. The things done to that purpose may not be desirable to someone who is already experienced in these subjects or even a beginner on the track to working in embedded systems as a career. There are other excellent options available for those people.

rodrigomorales:
For example, including "arduino.h" is not required when writing a new *.ino file, but it is if you are writing a library.

The Arduino IDE does a few things automatically to all .ino files in the sketch before renaming them with the .cpp (C++) extension and compiling them:

  • Concatenate all .ino files, starting with the file that matches the folder name, then the rest in alphabetical order.
  • Add #include <Arduino.h> if that line does not already exist.
  • Generate function prototypes for all functions that don't already have a prototype.
  • Add #line directives to make any warning/error messages generated by the resulting code still match the user's .ino files.

The Arduino IDE does not do any preprocessing of sketch files with extensions other than .ino. You can use .h, .cpp, .c, .hh, .hpp, .S files in your sketch if you like.

rodrigomorales:
So I wonder what is the impact of these IDE actions when writing programs for other boards.

Well, I'm not sure what you mean by "impact", I guess you can infer it yourself from what I said above or be more specific and I'll try to answer.

rodrigomorales:
Is the code of arduino.h added even if it is not used on other boards?

The Arduino.h include is always added to the .ino file unless it already exists but when you speak of "other boards", you should understand that each hardware package provides its own core library, which contains the Arduino.h file. The hardware package associated with the board you have selected in the Tools > Board menu is used during compilation. There is not one universal Arduino.h file used for all boards.

If you don't want Arduino.h included here's the way to accomplish that. Just add the following lines to your sketch:

#if false
#include <Arduino.h>
#endif

The sketch preprocessor sees that the line #include Arduino.h is already in the sketch and so doesn't add it. Now you'll find that all that Arduino core library magic to help beginners is gone. You can just have those three lines in your sketch and add files with regular .h/.c/.cpp extensions to program in regular old C, C++, assembly. Don't forget to define your main() function because the one defined in the Arduino core library will no longer be used.

rodrigomorales:
Another thing that I do not understand is why some of the "Core" libraries of the framework are located on the WiFi directory structure? And also duplicated (for example compiler.h which is located in C:\Program Files (x86)\Arduino\libraries\WiFi\extras\wifi_dnld\src\SOFTWARE_FRAMEWORK\UTILS) and in wifiHD...UTILS?

Some commonly-used constants like HIGH, or LOW are defined in "compiler.h". But, declaring them in wifi* directory does not make sense to me, if we accept that we can create a project on a board that does not contain a wiFi module, so why to create that dependency

If you have a look at the Arduino library specification:

The content of the extras folder is totally ignored by the IDE; you are free to put anything inside such as supporting documentation, etc.

I believe those files you see are for the firmware on the WiFi chip used on the Arduino WiFi shield, not for actually programming an Arduino board. That is not a dependency.