I am using Eclipse to program a ATMega2560 and would like to stay away from the Arduino library, While looking through AVR Examples I have seen the syntax

#include <avr/io.h>

PORTD.0 = 1



instead of

PORTD = 0b11111111;

To define and control the Inputs/Outputs when I try to use this syntax I get compiler errors:

error: request for member 'DIR' in '*34u', which is of non-class type 'volatile uint8_t {aka volatile unsigned char}'

I am sure that I am simply missing a include file or something but I can't figure out what I am doing wrong.

  • Where did you find the example code? That is not valid syntax for the AVR io definitions. Looks like PIC. – Mikael Patel May 19 '16 at 19:58
  • @MikaelPatel I have seen this quite a few times while searching for AVR, here is one site elecrom.com/2008/02/12/avr-tutorial-2-avr-input-output – Andy Braham May 19 '16 at 20:23
  • That is (as below) for another compiler (CodeVisionAVR) and not AVR-GCC which is used for the Arduino IDE. I guess that something similar (e.g. PORT[0]) could be defined in C++ using a class for Ports and an index operator. The dot operator (or struct) would have to be symbols (e.g. PORT.bit0). You could have a look at Cosa, github.com/mikaelpatel/Cosa. – Mikael Patel May 19 '16 at 22:24

What you're doing wrong is that you're using the wrong compiler. That syntax is for CodeVision or mikroC, but the Arduino IDE uses GCC. Which follows global standards rather than making syntax up.

| improve this answer | |
  • Holy cow! Alright I see, I thought CodeVision was an IDE or something. Too bad, that's a nice way of doing it. – Andy Braham May 19 '16 at 21:05

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.