1

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.

VE7JRO
2,51519 gold badges27 silver badges29 bronze badges
asked Nov 5, 2015 at 2:04
1
  • why the two down-votes on this recently? And 3 months later... Commented Feb 28, 2016 at 0:35

2 Answers 2

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.

answered Nov 5, 2015 at 2:11
6
  • So the function signatures within Arduino.h are defined by the libraries referenced, via the include statements shown in OP? Commented Nov 5, 2015 at 3:02
  • The headers referenced, yes. Commented 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? Commented Nov 5, 2015 at 3:30
  • Does avr/someLibrary.h mean to that someLibrary.h is contained in a directory called avr? Commented Nov 5, 2015 at 17:00
  • @skywalker: That is correct. Commented Nov 5, 2015 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.

answered Apr 27, 2019 at 11:21

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.