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– wgwz2016年02月28日 00:35:01 +00:00Commented Feb 28, 2016 at 0:35
2 Answers 2
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– wgwz2015年11月05日 03:02:01 +00:00Commented Nov 5, 2015 at 3:02
-
The headers referenced, yes.Ignacio Vazquez-Abrams– Ignacio Vazquez-Abrams2015年11月05日 03:13:13 +00:00Commented Nov 5, 2015 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– wgwz2015年11月05日 03:30:28 +00:00Commented Nov 5, 2015 at 3:30
-
Does avr/someLibrary.h mean to that someLibrary.h is contained in a directory called avr?wgwz– wgwz2015年11月05日 17:00:49 +00:00Commented Nov 5, 2015 at 17:00
-
@skywalker: That is correct.Ignacio Vazquez-Abrams– Ignacio Vazquez-Abrams2015年11月05日 17:17:12 +00:00Commented Nov 5, 2015 at 17:17
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.
Explore related questions
See similar questions with these tags.