Adafruit_SGP30.h and Adafruit_SGP40.h library issue

Post here about your Arduino projects, get help - for Adafruit customers!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
0miker0
 
Posts: 60
Joined: Mon Sep 12, 2011 8:13 am

Adafruit_SGP30.h and Adafruit_SGP40.h library issue

Post by 0miker0 »

When I run just the example sketch of just the Adafruit_SGP30.h or Adafruit_SGP40.h seperately there are no issues. When I combine both libraries together I get an error here:
Adafruit_SGP30 sgp;
Adafruit_SGP40 sgp; //ERROR

The error is:
note: previous declaration as 'Adafruit_SGP30 sgp'
Adafruit_SGP30 sgp;
^~~
exit status 1
Compilation error: conflicting declaration 'Adafruit_SGP40 sgp'

User avatar
adafruit_support_carter
 
Posts: 29189
Joined: Tue Nov 29, 2016 2:45 pm

Re: Adafruit_SGP30.h and Adafruit_SGP40.h library issue

Post by adafruit_support_carter »

You're trying to create two things with the same name. The first succeeds. The second fails (since name is already used).

Just give them different names:

Code: Select all

Adafruit_SGP30 sgp30;
Adafruit_SGP40 sgp40;

Locked
Please be positive and constructive with your questions and comments.

Return to “Arduino”