Inline function redeclaration when moved to a library

I prepared a sketch on the Editor, adding an inline function to my header file. Works fine.

I then moved that inline function to a header file in the library of the Editor. And deleted the inline function from the sketch header file.

No-go. Reports that the inline function was redeclared.

Does this make sense? What did I do wrong?

Without a link to the sketch or you posting it here its almost impossible to tell what might be wrong or how to fix it.

If you post it here please use code tags ( </> )

I have attached a URL for the sketch below.

The inline function is labeled analogReadFast(), and it is in the analog_interface.h tab.

I am trying to move the analogReadFast() inline function to the sthudium.h file in my Arduino Editor library.

Here is the sketch link. Arduino Cloud

Is there a downloadable link to the lib actually used ?

It looks like a call to a non existent lib or a badly named call.

Thanks ballscrewbob,

As requested, I have attached my "personal" library files.

They don't include the analogReadFast() function, so I have no problem with them.

But I get the problem after I move the inline analogReadFast() function from the analog_interface.h file to the sthudium.h file, by direct cut and paste.

sthudium.h (446 Bytes)

sthudium.cpp (994 Bytes)

You need to add an include guard to sthudium.h:

/*================================================================================ 
: FILE: sthudium.h
: Author: sthudium
: Email: sthudium@mac.com
: Date: 12/20/2017
: Revision: version 1
: License: Public Domain
:
: Personal library header file
================================================================================*/
#ifndef sthudium_h
#define sthudium_h
#include "Arduino.h"

void printTitle( String sketchTitle, int baud );
void maxLoops( const unsigned long loops );
int inline analogReadFast(byte ADCpin)
{ ADC->CTRLA.bit.ENABLE = 0;                     // Disable ADC;
  while( ADC->STATUS.bit.SYNCBUSY == 1 );        // Wait for synchronization;
  ADC->CTRLB.reg = ADC_CTRLB_PRESCALER_DIV64 |   // Divide Clock by 64;
                   ADC_CTRLB_RESSEL_10BIT; 
  ADC->AVGCTRL.reg = ADC_AVGCTRL_SAMPLENUM_1 |   // 1 sample;
                     ADC_AVGCTRL_ADJRES(0x00ul); // Adjusting result by 0;
  ADC->SAMPCTRL.reg = 0x00;                      // Sampling Time Length = 0;

  ADC->CTRLA.bit.ENABLE = 1;                     // Enable ADC;
  while( ADC->STATUS.bit.SYNCBUSY == 1 );        // Wait for synchronization;
  return analogRead(ADCpin);
}
#endif  //sthudium_h

BTW, it would have been much more helpful for you to post a link to the non-working sketch. I shouldn't have to do a bunch of work to reproduce your problem when you already have that code.

That worked. Thanks.