Help understanding and fixing 'INT_MODE_TYPE' has not been declared

Hello everyone new to Arduino and new to coding. I downloaded an Arduino menu library from github and I am receiving an error in the downloaded code attached below. I probably could have figured it out myself but perhaps you big brain experts could save me some time. As stated in title 'INT_MODE_TYPE' not declared for line 113. My first instinct was to attach unit8_t in that incorrect line of code but it didn't fix the problem so here I am. A general explanation of why this error is occurring would be appreciated as well as a replacement of corrected line of coding. Thanks in advanced guys and gals. *Updated error message added

/********************
Rui Azevedo - ruihfazevedo(@rrob@)gmail.com
adapted from: http://playground.arduino.cc/Main/PcInt
with many changes to make it compatible with arduino boards (original worked on Uno)
not tested on many boards but has the code uses arduino macros for pin mappings
it should be more compatible and also more easy to extend
some boards migh need pcintPinMap definition

Sept. 2014
  small changes to existing PCINT library, supporting an optional cargo parameter

Nov.2014 large changes
  - Use arduino standard macros for PCINT mapping instead of specific map math, broaden compatibility
  - array[a][b] is 17% faster than array[(a<<3)+b], same memory
  - reverse pin mappings for pin change check (not on arduino env. AFAIK)

**/
#ifndef ARDUINO_PCINT_MANAGER
#define ARDUINO_PCINT_MANAGER

	#if ARDUINO < 100
		#include <WProgram.h>
	#else
		#include <Arduino.h>
	#endif
	#include "pins_arduino.h"

	typedef void (*voidFuncPtr)(void);

	#define HANDLER_TYPE mixHandler

	/*#if (defined (_mk20dx128_h_) || defined (__MK20DX128__)) && defined (CORE_TEENSY)
	#define RSITE_TEENSY3
	#endif
	defined(RSITE_TEENSY3) || defined(ARDUINO_SAM_DUE)*/

	#if defined(__arm__) || defined(ESP8266) || defined(ESP32)
		#warning Compiling for arm
		#define PCINT_NO_MAPS
	#endif

	#ifndef PCINT_NO_MAPS
		// PCINT reverse map
		#if defined(digital_pin_to_pcint)
			#define digitalPinFromPCINTSlot(slot,bit) pgm_read_byte(digital_pin_to_pcint+(((slot)<<3)+(bit)))
			#define pcintPinMapBank(slot) ((uint8_t*)((uint8_t*)digital_pin_to_pcint+((slot)<<3)))
		#else
			#warning using maps!
			#if ( defined(__AVR_ATmega328__) || defined(__AVR_ATmega328P__) || defined(__AVR_ATmega16u4__) )
				//UNO
				const uint8_t pcintPinMap[3][8] PROGMEM={{8,9,10,11,12,13,0x80,0x80},{14,15,16,17,18,19,20,21},{0,1,2,3,4,5,6,7}};
			#elif ( defined(__AVR_ATmega2560__) )
				const uint8_t pcintPinMap[3][8] PROGMEM={{53,52,51,50,10,11,12,13},{0,15,14,0x80,0x80,0x80,0x80,0x80},{A8,A9,A10,A11,A12,A13,A14,A15}};
			#elif ( defined(__AVR_ATmega1284P__) || defined(__AVR_ATmega1284__) || defined(__AVR_ATmega644__))
				#error "uC PCINT REVERSE MAP IS NOT DEFINED, ATmega1284P variant unknown"
				//run the mkPCIntMap example to obtain a map for your board!
			#else
				#warning "uC PCINT REVERSE MAP IS NOT DEFINED"
				//run the mkPCIntMap example to obtain a map for your board!
			#endif
			#define digitalPinFromPCINTSlot(slot,bit) pgm_read_byte(pcintPinMap+(((slot)<<3)+(bit)))
			#define pcintPinMapBank(slot) ((uint8_t*)((uint8_t*)pcintPinMap+((slot)<<3)))
		#endif
		#define digitalPinFromPCINTBank(bank,bit) pgm_read_byte((uint8_t*)bank+bit)

	#endif

	//this handler can be used instead of any void(*)() and optionally it can have an associated void *
	//and use it to call void(*)(void* payload)
	struct mixHandler {
		union {
			void (*voidFunc)(void);
			void (*payloadFunc)(void*);
		} handler;
		void *payload;
		inline mixHandler():payload(NULL) {handler.voidFunc=NULL;}
		inline mixHandler(void (*f)(void)):payload(NULL) {handler.voidFunc=f;}
		inline mixHandler(void (*f)(void*),void *payload):payload(payload) {handler.payloadFunc=f;}
		inline void operator()() {payload?handler.payloadFunc(payload):handler.voidFunc();}
		inline bool operator==(void*ptr) {return handler.voidFunc==ptr;}
		inline bool operator!=(void*ptr) {return handler.voidFunc!=ptr;}
	};

	#ifdef PCINT_NO_MAPS
	  #if  defined(__STM32F1__) || defined(__STM32F4__) // https://github.com/rogerclarkmelbourne/Arduino_STM32
	    #define INT_MODE_TYPE ExtIntTriggerMode
	    #define NUM_DIGITAL_PINS BOARD_NR_GPIO_PINS
	  #else
            #define INT_MODE_TYPE uint8_t
	  #endif
	  
	  extern HANDLER_TYPE PCintFunc[NUM_DIGITAL_PINS];
	  template<uint8_t N> void PCint() {PCintFunc[N]();}
	#else
	void PCattachInterrupt(uint8_t pin,HANDLER_TYPE userFunc, uint8_t mode);
	void PCdetachInterrupt(uint8_t pin);

	// common code for isr handler. "port" is the PCINT number.
	// there isn't really a good way to back-map ports and masks to pins.
	// here we consider only the first change found ignoring subsequent, assuming no interrupt cascade
	// static void PCint(uint8_t port);

	#endif
	/*
	 * attach an interrupt to a specific pin using pin change interrupts.
	 */
	template<uint8_t PIN>
	void PCattachInterrupt(HANDLER_TYPE userFunc, INT_MODE_TYPE mode) {
	  #ifdef PCINT_NO_MAPS
			PCintFunc[PIN]=userFunc;
	    attachInterrupt(digitalPinToInterrupt(PIN),PCint<PIN>,mode);
	  #else
			PCattachInterrupt(PIN,userFunc,mode);
	  #endif
	}

	template<uint8_t PIN>
	void PCdetachInterrupt() {
		#ifdef PCINT_NO_MAPS
	    detachInterrupt(PIN);
	  #else
			PCdetachInterrupt(PIN);
	  #endif
	}


#endif

ERROR CODE BELOW

`C:\Users\jojom\AppData\Local\Temp\.arduinoIDE-unsaved2023021-17876-ahqprk.kdtr\sketch_jan21b\sketch_jan21b.ino:113:48: error: 'INT_MODE_TYPE' has not been declared
    PCattachInterrupt(PIN,userFunc,mode);
                                                ^            

exit status 1

Compilation error: 'INT_MODE_TYPE' has not been declared`

It's best to follow the guidelines and post the actual error message, in its entirety.

Sorry I am still new, I just assumed you would copy and paste the code and see for yourself. Thank you for the correction.

It is generally more convenient if you post the full error message as there are often several and, of course, many members read the forum on portable devices and cannot compile the code

Copy and paste it to where?
Elsewhere on my phone?
Where is the rest of the error message?

There is a bunch of conditional compilation based on the processor you are compiling for. What model Arduino did you select under Tools -> Board before you tried to compile?

That was the entirety of the error code that is posted after the primary code. I am using an arduino mega 2560. Is this code only for a regular uno or something? I'm confused on what the significance of that information is when I am only verifying the code not uploading it to the board as of yet. Sorry for any confusion guys. I guess the main questions I have are "What causes this int mode type not declared error", "How could I fix this" etc...

This is a widely used arduino menu library that I've downloaded from github and its giving me this error code right off the bat before I even tamper with anything so I'm a bit confused. Ive checked the issues section and there was nothing so i figured one of you could help.

Usually, there's more to it than that, including stuff like the selected processor.
Is that just the bit that was visible in the error pane?
The IDE has a control "copy error messages" (or something like that) - did you use it?

Please provide a link to the GitHub location where this code comes from.

pcint.h is the file inside the library in which the error code originates.

You guys going to ask for my social security number next?

No, but if you actually want help from the forum volunteers, provide the required information and answer the questions as completely as possible.

For more posting hints, see the "How to get the best out of this forum" linked at the head of every forum topic.

You've posted a link to the library but haven't posted your code that attempts to use the library. It seem logical that would be required to help solve your problem.

Sorry guys bad attempt at humor. I'm just having a hard time understanding why some of you are asking non pertinent questions. But anyways considering that the error lies in the library file it would'nt be 'logical' to need my code but here it is anyways. I'm merely trying to execute an example given on that same github page. Sort of a step backwards. Not trying to ridicule the people nice enough to help me I'm just lost in understanding how this is necessary....

#include <Arduino.h>

/********************
Arduino generic menu system
U8GLib menu example
U8Glib: https://github.com/olikraus/U8glib_Arduino

Jul.2016 Rui Azevedo - ruihfazevedo(@rrob@)gmail.com
Original from: https://github.com/christophepersoz

menu on U8GLib device
output: Nokia 5110 display (PCD8544 HW SPI) + Serial
input: Serial + encoder

ESP8266 Compile Error:
  `.irom0.text' will not fit in region `irom0_0_seg'
  see: http://bbs.espressif.com/viewtopic.php?t=166

please use U8G2 instead.

*/

#include <U8glib.h>
#include <menu.h>
#include <menuIO/encoderIn.h>
#include <menuIO/keyIn.h>
#include <menuIO/chainStream.h>
#include <menuIO/serialOut.h>
#include <menuIO/serialIn.h>
#include <menuIO/U8GLibOut.h>

using namespace Menu;

#define LEDPIN LED_BUILTIN

// rotary encoder pins
#define encA    2
#define encB    3
#define encBtn  4

#define U8_DC 9
#define U8_CS 8
#define U8_RST 7

U8GLIB_PCD8544 u8g(U8_CS, U8_DC, U8_RST) ;

result doAlert(eventMask e, prompt &item);

result showEvent(eventMask e,navNode& nav,prompt& item) {
  Serial.print("event: ");
  Serial.println(e);
  return proceed;
}

int test=55;

result action1(eventMask e) {
  Serial.print(e);
  Serial.println(" action1 executed, proceed menu");
  Serial.flush();
  return proceed;
}

result action2(eventMask e,navNode& nav, prompt &item) {
  Serial.print(e);
  Serial.print(" action2 executed, quiting menu");
  return quit;
}

int ledCtrl=LOW;

result myLedOn() {
  ledCtrl=HIGH;
  return proceed;
}
result myLedOff() {
  ledCtrl=LOW;
  return proceed;
}

TOGGLE(ledCtrl,setLed,"Led: ",doNothing,noEvent,noStyle
  ,VALUE("On",HIGH,doNothing,noEvent)
  ,VALUE("Off",LOW,doNothing,noEvent)
);

int selTest=0;
SELECT(selTest,selMenu,"Select",doNothing,noEvent,noStyle
  ,VALUE("Zero",0,doNothing,noEvent)
  ,VALUE("One",1,doNothing,noEvent)
  ,VALUE("Two",2,doNothing,noEvent)
);

int chooseTest=-1;
CHOOSE(chooseTest,chooseMenu,"Choose",doNothing,noEvent,noStyle
  ,VALUE("First",1,doNothing,noEvent)
  ,VALUE("Second",2,doNothing,noEvent)
  ,VALUE("Third",3,doNothing,noEvent)
  ,VALUE("Last",-1,doNothing,noEvent)
);

//customizing a prompt look!
//by extending the prompt class
class altPrompt:public prompt {
public:
  altPrompt(constMEM promptShadow& p):prompt(p) {}
  Used printTo(navRoot &root,bool sel,menuOut& out, idx_t idx,idx_t len,idx_t panelNr) override {
    return out.printRaw(F("special prompt!"),len);;
  }
};

MENU(subMenu,"Sub-Menu",showEvent,anyEvent,noStyle
  ,OP("Sub1",showEvent,anyEvent)
  ,OP("Sub2",showEvent,anyEvent)
  ,OP("Sub3",showEvent,anyEvent)
  ,altOP(altPrompt,"",showEvent,anyEvent)
  ,EXIT("<Back")
);

const char* constMEM hexDigit MEMMODE="0123456789ABCDEF";
const char* constMEM hexNr[] MEMMODE={"0","x",hexDigit,hexDigit};
char buf1[]="0x11";

MENU(mainMenu,"Main menu",doNothing,noEvent,wrapStyle
  ,OP("Op1",action1,anyEvent)
  ,OP("Op2",action2,enterEvent)
  ,FIELD(test,"Test","%",0,100,10,1,doNothing,noEvent,wrapStyle)
  ,EDIT("Hex",buf1,hexNr,doNothing,noEvent,noStyle)
  ,SUBMENU(subMenu)
  ,SUBMENU(setLed)
  ,OP("LED On",myLedOn,enterEvent)
  ,OP("LED Off",myLedOff,enterEvent)
  ,SUBMENU(selMenu)
  ,SUBMENU(chooseMenu)
  ,OP("Alert test",doAlert,enterEvent)
  ,EXIT("<Back")
);

// define menu colors --------------------------------------------------------
//each color is in the format:
//  {{disabled normal,disabled selected},{enabled normal,enabled selected, enabled editing}}
// this is a monochromatic color table
const colorDef<uint8_t> colors[6] MEMMODE={
  {{0,0},{0,1,1}},//bgColor
  {{1,1},{1,0,0}},//fgColor
  {{1,1},{1,0,0}},//valColor
  {{1,1},{1,0,0}},//unitColor
  {{0,1},{0,0,1}},//cursorColor
  {{0,0},{1,1,1}},//titleColor
};

encoderIn<encA,encB> encoder;//simple quad encoder driver
encoderInStream<encA,encB> encStream(encoder,4);// simple quad encoder fake Stream

//a keyboard with only one key as the encoder button
keyMap encBtn_map[]={{-encBtn,defaultNavCodes[enterCmd].ch}};//negative pin numbers use internal pull-up, on = low
keyIn<1> encButton(encBtn_map);//1 is the number of keys

serialIn serial(Serial);

//input from the encoder + encoder button + serial
menuIn* inputsList[]={&encStream,&encButton,&serial};
chainStream<3> in(inputsList);//3 is the number of inputs

//fontY should now account for fontMarginY
#define fontX 6
#define fontY 9
#define MAX_DEPTH 2

//this macro replaces all the above commented lines
MENU_OUTPUTS(out,MAX_DEPTH
  ,U8GLIB_OUT(u8g,colors,fontX,fontY,{0,0,84/fontX,48/fontY})
  ,SERIAL_OUT(Serial)
);

NAVROOT(nav,mainMenu,MAX_DEPTH,in,out);

result alert(menuOut& o,idleEvent e) {
  if (e==idling) {
    o.setCursor(0,0);
    o.print("alert test");
    o.setCursor(0,1);
    o.print("press [select]");
    o.setCursor(0,2);
    o.print("to continue...");
  }
  return proceed;
}

result doAlert(eventMask e, prompt &item) {
  nav.idleOn(alert);
  return proceed;
}

//when menu is suspended
result idle(menuOut& o,idleEvent e) {
  o.clear();
  switch(e) {
    case idleStart:o.println("suspending menu!");break;
    case idling:o.println("suspended...");break;
    case idleEnd:o.println("resuming menu.");break;
  }
  return proceed;
}

void setup() {
  pinMode(LEDPIN,OUTPUT);
  Serial.begin(115200);
  while(!Serial);
  nav.idleTask=idle;//point a function to be used when menu is suspended
  mainMenu[1].enabled=disabledStatus;
  //change input burst for slow output devices
  //this is the number of max. processed inputs before drawing
  nav.inputBurst=10;

  pinMode(encBtn, INPUT_PULLUP);
  encButton.begin();
  encoder.begin();

  //u8g.setFont(u8g_font_helvR08);
  u8g.setFont(u8g_font_6x10);
  //u8g.setFont(u8g_font_04b_03r);
  u8g.firstPage();
  do {
    u8g.setColorIndex(1);
    nav.out[0].setCursor(0,0);
    nav.out[0].print(F("Menu 4.x test"));
    nav.out[0].setCursor(0,1);
    nav.out[0].print(F("on U8Glib"));
  } while(u8g.nextPage());
  delay(1000);
}

void loop() {
  nav.doInput();
  digitalWrite(LEDPIN, ledCtrl);
  if (nav.changed(0)) {//only draw if menu changed for gfx device
    //because this code clears the screen, if always called then screen will blink
    u8g.firstPage();
    do nav.doOutput(); while(u8g.nextPage());
  }
  delay(100);//simulate other tasks delay
}

So simplistically put as possible. Has anyone worked with this function before "PCattachInterrupt(PIN,userFunc,mode);" and is familiar with its necessary formatting? Has anyone experienced a "Compilation error: 'INT_MODE_TYPE' has not been declared" error when dealing with this function or in general?

If your answer is no to the either/both of the above questions I suggest you attempt to run the code on the initial post for better understanding before asking any additional questions. There is no need for further clutter this thread with non pertinent information.

Apparently not.

I'm just having a hard time understanding why some of you are asking non pertinent questions.

What you're seeing is people NOT familiar with the library you're using, that are trying to help anyway, so every little bit of information IS "pertinent", since the first thing we're liable to want to try is recompiling "locally."

FWIW, I think I tracked down all the libraries and whatnot that you are using, and attempted a compile, and I did NOT get the same error you are using (though I did get the "doesn't fit" error from Link.)

Are you sure you're using the correct PCINT library? The menu library says specifically GitHub - neu-rah/PCINT: Yet another Arduino PCINT library, which is NOT either of the two libraries that show up when you search for "pcint" in the IDE's "library manager"...

It looks to me like the problem might have been introduced in the latest version, modified May 23rd, 2020.

It looks like when adding support for STM32F1 and STM32F4 processors they had to make the RISING/FALLING/CHANGE argument something other than 'uint8_t'. They did that by defining "INT_MODE_TYPE" but it seems they only do that when "PCINT_NO_MAPS" is defined. I don't think they tested on a MEGA after making this change.

I think it can be fixed by adding a line:

	#else
          #define INT_MODE_TYPE uint8_t
	  void PCattachInterrupt(uint8_t pin,HANDLER_TYPE userFunc, uint8_t mode);
	  void PCdetachInterrupt(uint8_t pin);

	// common code for isr handler. "port" is the PCINT number.
	// there isn't really a good way to back-map ports and masks to pins.
	// here we consider only the first change found ignoring subsequent, assuming no interrupt cascade
	// static void PCint(uint8_t port);

	#endif
1 Like

Yea that's where I downloaded it from originally. I deleted it from my library and tried the pcint directly from arduino IDE to no avail.

I think you may be on the right track but now it gives me this error code.

C:\Users\jojom\AppData\Local\Temp\ccsLduNG.ltrans0.ltrans.o: In function `main':
C:\Users\jojom\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\cores\arduino/main.cpp:43: undefined reference to `setup'
C:\Users\jojom\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\cores\arduino/main.cpp:46: undefined reference to `loop'
collect2.exe: error: ld returned 1 exit status

exit status 1

Compilation error: exit status 1