Issue with AtmelStudio: Code in Arduino IDE compiles, in AtmelStudio doesn't

Hi,
today I've upgraded to AtmelStudio 6 with Arduino Extension. My own projects work great in there. Code browsing is much more easy, and digging into the libraries also.

But I have encountered one strange problem:
When I tried to compile the PCF8574 example from GitHub - skywodd/pcf8574_arduino_library: PCF8574 / PCF8575 Arduino library (version 2.0) it will work in the Arduino IDE but not in Studio.

IDE:

Compiling 'ButtonBlink' for 'Arduino Uno'
ButtonBlink.ino:16:9: error: no matching function for call to 'PCF8574::PCF8574()'
ButtonBlink.ino:candidates are
PCF8574.h:PCF8574(int)
PCF8574.h:candidate expects 1 argument, 0 provided
PCF8574.h:PCF8574(const PCF8574&)
PCF8574.h:candidate expects 1 argument, 0 provided
ButtonBlink.ino:In function 'void setup()'
ButtonBlink.ino:25:12: error: 'class PCF8574' has no member named 'begin'
ButtonBlink.ino:28:12: error: 'class PCF8574' has no member named 'pinMode'
ButtonBlink.ino:29:12: error: 'class PCF8574' has no member named 'pinMode'
ButtonBlink.ino:30:12: error: 'class PCF8574' has no member named 'pinMode'
ButtonBlink.ino:31:12: error: 'class PCF8574' has no member named 'pinMode'
ButtonBlink.ino:34:12: error: 'class PCF8574' has no member named 'enableInterrupt'
ButtonBlink.ino:37:12: error: 'class PCF8574' has no member named 'attachInterrupt'
ButtonBlink.ino:38:12: error: 'class PCF8574' has no member named 'digitalWrite'
ButtonBlink.ino:In function 'void ISRgateway()'
ButtonBlink.ino:43:12: error: 'class PCF8574' has no member named 'checkForInterrupt'
ButtonBlink.ino:In function 'void ISRdemo()'
ButtonBlink.ino:53:19: error: no matching function for call to 'PCF8574::toggle()'
ButtonBlink.ino:candidate is
PCF8574.h:toggle(uint8_t)
PCF8574.h:candidate expects 1 argument, 0 provided
ButtonBlink.ino:In function 'void loop()'
ButtonBlink.ino:63:12: error: 'class PCF8574' has no member named 'blink'
ButtonBlink.ino:65:12: error: 'class PCF8574' has no member named 'blink'
ButtonBlink.ino:69:12: error: 'class PCF8574' has no member named 'digitalWrite'
ButtonBlink.ino:71:12: error: 'class PCF8574' has no member named 'digitalWrite'
ButtonBlink.ino:73:12: error: 'class PCF8574' has no member named 'digitalWrite'
ButtonBlink.ino:75:12: error: 'class PCF8574' has no member named 'digitalWrite'
ButtonBlink.ino:93:12: error: 'class PCF8574' has no member named 'detachInterrupt'
ButtonBlink.ino:95:27: error: 'class PCF8574' has no member named 'digitalRead'
ButtonBlink.ino:96:32: error: no matching function for call to 'PCF8574::read()'
ButtonBlink.ino:candidate is
PCF8574.h:read(uint8_t)
PCF8574.h:candidate expects 1 argument, 0 provided
ButtonBlink.ino:97:12: error: 'class PCF8574' has no member named 'attachInterrupt'
Error compiling

In No. 16 the instance should be created:

PCF8574 expander;

Here is minimal code that should work (works in A-IDE) if you install the library:

#include <Wire.h>    // Required for I2C communication
#include "PCF8574.h" // Required for PCF8574

PCF8574 expander;

void setup() {
  expander.begin(0x20);
}

void loop() {
}

Again Atmel Studio complains:

Compiling 'ButtonBlink' for 'Arduino Uno'
ButtonBlink.ino:4:9: error: no matching function for call to 'PCF8574::PCF8574()'
ButtonBlink.ino:candidates are
PCF8574.h:PCF8574(int)
PCF8574.h:candidate expects 1 argument, 0 provided
PCF8574.h:PCF8574(const PCF8574&)
PCF8574.h:candidate expects 1 argument, 0 provided
ButtonBlink.ino:In function 'void setup()'
ButtonBlink.ino:7:12: error: 'class PCF8574' has no member named 'begin'
Error compiling

I appreciate any help...
Matthias

Edit: Quick link to the library:

it will work in the Arduino IDE but not in Studio.

What did they say at the AtmelStudio forum?

I didn't ask there... Aren't questions regarding other software welcome to this forum?

I've solved the problem by commenting the interrupt function out. I don't know why, but now it works.

Thanks,
Matthias

I have no idea what you mean by "Arduino extension", but if you install the (free) VisualMicro plug-in from visualmicro.com, ALL Arduino programs will build correctly in Atmel Studio.

Regards,
Ray L.

Mettwurstbrot:
I didn't ask there... Aren't questions regarding other software welcome to this forum?

It's not that they're not welcome, it's just if I had a problem with some software, my first thought would be "I'll ask the people who wrote/support that software, not some other unconnected group".
But maybe that's just me.

Are they the identical library? It looks like the constructor is expecting an int argument and not getting it.

See: Arduino Playground - PCF8574Class

Example code:

#include "PCF8574.h"
#include <Wire.h>

// adjust addresses if needed
PCF8574 PCF_38(0x38);  // add switches to lines  (used as input)
PCF8574 PCF_39(0x39);  // add leds to lines      (used as output)

Constructor is taking an argument.

In the library code:

class PCF8574
{
  public:
  PCF8574(int address);

Constructor needs an int.

However the GitHub code you linked is different:

class PCF8574 {
public:
	/**
	 * Create a new PCF8574 instance
	 */
	PCF8574();

Constructor does not take an int.

My conclusion: You have two different copies of the library.

Thanks a lot for the hints and help. I've reinstalled the library and everything works. I will try to find the real issue tomorrow... Yes it is the Plugin from visual Micro.

Best,
Matthias