0

This is more of a C/C++ question. However the files I am asking about are a part of the Arduino library.

In /arduino-1.6.5-r5/hardware/arduino/avr/cores/arduino/Arduino.h :

#ifndef Arduino_h
#define Arduino_h

#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include <math.h>

#include <avr/pgmspace.h>
#include <avr/io.h>
#include <avr/interrupt.h>

#include "binary.h"

#ifdef __cplusplus
extern "C"{
#endif

How are these blocks found at compile time in the main sketch?

#include <avr/pgmspace.h>
#include <avr/io.h>
#include <avr/interrupt.h>

Does #include <avr/somelibrary.h> mean that this is a standard library from either avr-g++ or avr-gcc? As opposed to a standard g++ or gcc compiler?

One last question, how can there be an Arduino.h without an Arduino.c? I searched through the project but could not find an Arduino.c. All of these are probably stupid questions, as I am in the process of learning C/C++. I am completely new to it.

  • why the two down-votes on this recently? And 3 months later... – wgwz Feb 28 '16 at 0:35
1

Does #include <avr/somelibrary.h> mean that this is a standard library from either avr-g++ or avr-gcc? As opposed to a standard g++ or gcc compiler?

No. It simply means that the compiler should check both its built-in include paths as well as any passed via the -I command line option (or its local equivalent) for a file called "avr/somelibrary.h". That AVR GCC knows where AVR Libc is located is incidental.

One last question, how can there be an Arduino.h without an Arduino.c?

There is no obligation to match each header file with a .c/.cc/.cpp file, or vice versa.

  • So the function signatures within Arduino.h are defined by the libraries referenced, via the include statements shown in OP? – wgwz Nov 5 '15 at 3:02
  • The headers referenced, yes. – Ignacio Vazquez-Abrams Nov 5 '15 at 3:13
  • Suppose there is an include in an include, so to speak. Would the header file pick up functions to the second level? – wgwz Nov 5 '15 at 3:30
  • Does avr/someLibrary.h mean to that someLibrary.h is contained in a directory called avr? – wgwz Nov 5 '15 at 17:00
  • @skywalker: That is correct. – Ignacio Vazquez-Abrams Nov 5 '15 at 17:17
0

I think after all this time, you may found the answers for your question.

But to add some information to this topic incase if anyone opened this question.

Does #include mean that this is a standard library from either avr-g++ or avr-gcc? As opposed to a standard g++ or gcc compiler?

Yes, what is included with avr/ is related to avr standard libraries, which is also found in avr standard compilers.

One last question, how can there be an Arduino.h without an Arduino.c?

Because, as Mr @Ignacio Vazquez-Abrams answered that there's no obligation for connecting the header file for anything else. You can write multiple header files and use them for one source file.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.