Nextion Display Problem with attachPop


I am currently working on a Nextion Display with an Arduino Due. I want to keep track of the current page on the display, therefore I want to update the variable pageNum every time the swtichPage button is pressed.


#ifndef _DISPLAY_h
#define _DISPLAY_h

#include "Nextion.h"

class CDisplay {
  void init();
  void process();
  void switchPagePopCallback(void * ptr);
  NexTouch *nex_listen_list[];

  uint16_t Voltage;
  NexText t_Vol;
  NexButton switchPage;
  char voltString[];
  uint8_t pageNum;



#include "Display.h"

  int Voltage = 0;
  char voltString[]=" V";
  uint8_t pageNum=1;

void CDisplay::switchPagePopCallback(void *ptr){
  pageNum= 2;

void CDisplay::init(){

  NexTouch *nex_listen_list[]{

void CDisplay::process(){
  char tbuff[10];
  char tbuff2[10];


#include <Arduino.h>
#include "Display.h"

CDisplay Display;

void setup() {
  // put your setup code here, to run once:

void loop() {
  // put your main code here, to run repeatedly:

When compiling this error occures:

exit status 1
no matching function for call to ‘NexButton::attachPop(, NexButton*)’

If I programm the code in one file (w/o a seperate display class) everything works fine…

I would be very grateful for any kind of advice!

I would be very grateful for any kind of advice!

Don't use non static member functions for callbacks, they only accept plain (or static) functions.