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,515
  • 19
  • 27
  • 29
wgwz
  • 149
  • 1
  • 7

2 Answers2

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.

Ignacio Vazquez-Abrams
  • 17,733
  • 1
  • 28
  • 32
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.

R1S8K
  • 283
  • 3
  • 21