[SOLVED almost]args of function an array of struct with unknow size at compil

Hello,
i want get an array of data of variable size from db for use in another function.
I write that but Arduino don't want it.
I begin with C C++ sorry.

typedef struct mySceneAction
{
  unsigned int id;
  unsigned int sceneId;
  unsigned int orderAction;
  unsigned int ioRemoteId;
  unsigned int ioRemoteChannel;
  unsigned int ioRemoteAction;
} mySceneAction;

void sceneRun(int sceneId)
{
  // get nb of action to do with this scene id
  const unsigned int nbSceneAction = dbCountSceneAction(sceneId);
  mySceneAction sceneAction[nbSceneAction];
  if (dbLoadSceneAction(sceneId, &sceneAction)) { // ERROR : cannot convert 'mySceneAction (*)[nbSceneAction]' to 'mySceneAction**' for argument '2' to 'bool dbLoadSceneAction(int, mySceneAction**)'
    // do something with array of data
  }
}

bool dbLoadSceneAction(int sceneId, struct mySceneAction* sceneAction[])
{
  // get data from db
}

if anyone can help me find the right path i would be very grateful.
I don't want use class else i must rewrite all to oriented object.
Thanks.

Please post a full example of the problem, not just a snippet, and the full error message, if any, or else a description of what happens when you run the program

ok here sample:

typedef struct mySceneAction
{
  unsigned int id;
  unsigned int sceneId;
  unsigned int orderAction;
  unsigned int ioRemoteId;
  unsigned int ioRemoteChannel;
  unsigned int ioRemoteAction;
} mySceneAction;

int dbCountSceneAction(int sceneId)
{
  //get nb from db
  return 3; // exemple
}

void sceneRun(int sceneId)
{
  // get nb of action to do with this scene id
  const unsigned int nbSceneAction = dbCountSceneAction(sceneId);
  mySceneAction sceneAction[nbSceneAction];
  if (dbLoadSceneAction(sceneId, &sceneAction)) { // ERROR : cannot convert 'mySceneAction (*)[nbSceneAction]' to 'mySceneAction**' for argument '2' to 'bool dbLoadSceneAction(int, mySceneAction**)'
    // do something with array of data
  }
}

bool dbLoadSceneAction(int sceneId, struct mySceneAction* sceneAction[])
{
  // get data from db
}

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

}

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

full error message cannot be post "The message exceeds the maximum allowed length (9000 characters).":

Arduino : 1.8.13 (Windows 10), Carte : "ESP32 Dev Module, Disabled, Default 4MB with spiffs (1.2MB APP/1.5MB SPIFFS), 240MHz (WiFi/BT), QIO, 80MHz, 4MB (32Mb), 921600, Verbose"

Y:\mes_programmes\Arduino\arduino-1.8.13\arduino-builder -dump-prefs -logger=machine -hardware Y:\mes_programmes\Arduino\arduino-1.8.13\hardware -hardware C:\Users\MAMANPAPA\AppData\Local\Arduino15\packages -tools Y:\mes_programmes\Arduino\arduino-1.8.13\tools-builder -tools Y:\mes_programmes\Arduino\arduino-1.8.13\hardware\tools\avr -tools C:\Users\MAMANPAPA\AppData\Local\Arduino15\packages -built-in-libraries Y:\mes_programmes\Arduino\arduino-1.8.13\libraries -libraries D:\Documents\Arduino\libraries -fqbn=esp32:esp32:esp32:PSRAM=disabled,PartitionScheme=default,CPUFreq=240,FlashMode=qio,FlashFreq=80,FlashSize=4M,UploadSpeed=921600,DebugLevel=verbose -vid-pid=10C4_EA60 -ide-version=10813 -build-path C:\Users\MAMANP~1\AppData\Local\Temp\arduino_build_209357 -warnings=all -build-cache C:\Users\MAMANP~1\AppData\Local\Temp\arduino_cache_21192 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.xtensa-esp32-elf-gcc.path=C:\Users\MAMANPAPA\AppData\Local\Arduino15\packages\esp32\tools\xtensa-esp32-elf-gcc\1.22.0-80-g6c4433a-5.2.0 -prefs=runtime.tools.xtensa-esp32-elf-gcc-1.22.0-80-g6c4433a-5.2.0.path=C:\Users\MAMANPAPA\AppData\Local\Arduino15\packages\esp32\tools\xtensa-esp32-elf-gcc\1.22.0-80-g6c4433a-5.2.0 -prefs=runtime.tools.esptool_py.path=C:\Users\MAMANPAPA\AppData\Local\Arduino15\packages\esp32\tools\esptool_py\2.6.1 -prefs=runtime.tools.esptool_py-2.6.1.path=C:\Users\MAMANPAPA\AppData\Local\Arduino15\packages\esp32\tools\esptool_py\2.6.1 -prefs=runtime.tools.mkspiffs.path=C:\Users\MAMANPAPA\AppData\Local\Arduino15\packages\esp32\tools\mkspiffs\0.2.3 -prefs=runtime.tools.mkspiffs-0.2.3.path=C:\Users\MAMANPAPA\AppData\Local\Arduino15\packages\esp32\tools\mkspiffs\0.2.3 -verbose D:\Documents\Arduino\sketch_oct05a\sketch_oct05a.ino

Y:\mes_programmes\Arduino\arduino-1.8.13\arduino-builder -compile -logger=machine -hardware Y:\mes_programmes\Arduino\arduino-1.8.13\hardware -hardware C:\Users\MAMANPAPA\AppData\Local\Arduino15\packages -tools Y:\mes_programmes\Arduino\arduino-1.8.13\tools-builder -tools Y:\mes_programmes\Arduino\arduino-1.8.13\hardware\tools\avr -tools C:\Users\MAMANPAPA\AppData\Local\Arduino15\packages -built-in-libraries Y:\mes_programmes\Arduino\arduino-1.8.13\libraries -libraries D:\Documents\Arduino\libraries -fqbn=esp32:esp32:esp32:PSRAM=disabled,PartitionScheme=default,CPUFreq=240,FlashMode=qio,FlashFreq=80,FlashSize=4M,UploadSpeed=921600,DebugLevel=verbose -vid-pid=10C4_EA60 -ide-version=10813 -build-path C:\Users\MAMANP~1\AppData\Local\Temp\arduino_build_209357 -warnings=all -build-cache C:\Users\MAMANP~1\AppData\Local\Temp\arduino_cache_21192 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.xtensa-esp32-elf-gcc.path=C:\Users\MAMANPAPA\AppData\Local\Arduino15\packages\esp32\tools\xtensa-esp32-elf-gcc\1.22.0-80-g6c4433a-5.2.0 -prefs=runtime.tools.xtensa-esp32-elf-gcc-1.22.0-80-g6c4433a-5.2.0.path=C:\Users\MAMANPAPA\AppData\Local\Arduino15\packages\esp32\tools\xtensa-esp32-elf-gcc\1.22.0-80-g6c4433a-5.2.0 -prefs=runtime.tools.esptool_py.path=C:\Users\MAMANPAPA\AppData\Local\Arduino15\packages\esp32\tools\esptool_py\2.6.1 -prefs=runtime.tools.esptool_py-2.6.1.path=C:\Users\MAMANPAPA\AppData\Local\Arduino15\packages\esp32\tools\esptool_py\2.6.1 -prefs=runtime.tools.mkspiffs.path=C:\Users\MAMANPAPA\AppData\Local\Arduino15\packages\esp32\tools\mkspiffs\0.2.3 -prefs=runtime.tools.mkspiffs-0.2.3.path=C:\Users\MAMANPAPA\AppData\Local\Arduino15\packages\esp32\tools\mkspiffs\0.2.3 -verbose D:\Documents\Arduino\sketch_oct05a\sketch_oct05a.ino

Using board 'esp32' from platform in folder: C:\Users\MAMANPAPA\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4

Using core 'esp32' from platform in folder: C:\Users\MAMANPAPA\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4

Detecting libraries used...
//removed "The message exceeds the maximum allowed length (9000 characters)."

Generating function prototypes...
//removed "The message exceeds the maximum allowed length (9000 characters)."

Compilation du croquis...
//removed "The message exceeds the maximum allowed length (9000 characters)."

D:\Documents\Arduino\sketch_oct05a\sketch_oct05a.ino: In function 'void sceneRun(int)':

sketch_oct05a:23:46: error: cannot convert 'mySceneAction (*)[nbSceneAction]' to 'mySceneAction**' for argument '2' to 'bool dbLoadSceneAction(int, mySceneAction**)'

if (dbLoadSceneAction(sceneId, &sceneAction)) { // ERROR : cannot convert 'mySceneAction (*)[nbSceneAction]' to 'mySceneAction**' for argument '2' to 'bool dbLoadSceneAction(int, mySceneAction**)'

^

D:\Documents\Arduino\sketch_oct05a\sketch_oct05a.ino: In function 'bool dbLoadSceneAction(int, mySceneAction**)':

sketch_oct05a:31:1: error: no return statement in function returning non-void [-Werror=return-type]

}

^

cc1plus.exe: some warnings being treated as errors

exit status 1

cannot convert 'mySceneAction (*)[nbSceneAction]' to 'mySceneAction**' for argument '2' to 'bool dbLoadSceneAction(int, mySceneAction**)'

Thanks for the help.

bool dbLoadSceneAction(int sceneId, struct mySceneAction* sceneAction[])
{
  // get data from db
}

Well first of all you are not returning a variable for a 'bool' type function.
secondly

mySceneAction sceneAction[nbSceneAction];
  if (dbLoadSceneAction(sceneId, &sceneAction))

sceneaction is an array of pointers or to be more exact, a pointer to an array of pointers. I am not to good at this, but i suspect that it should be

mySceneAction sceneAction[nbSceneAction];
  if (dbLoadSceneAction(sceneId, &sceneAction[]))

Though i may of course be mistaken. anyway, you provide a pointer to an array, but you need to provide a pointer to an array of pointers.

The parameters for the dbLoadSceneAction() function should look like this:

bool dbLoadSceneAction(int sceneId, struct mySceneAction *sceneAction) {
  // get data from db
  return true;
}

And, as noted, the function must return a bool because you promised the compiler it would.

The call to dbLoadSceneAction() should look like this:

 if (dbLoadSceneAction(sceneId, sceneAction)) {
    // do something with array of data
  }

Hello, you have right for "return true" but its a little error in sample, not the real problem.

Have you tried what you say before reply with sample i provide ? Me yes it don't work.

I use a workarround (if someone have solution for the first issue please post thanks but else dont reply PLEASE)

so i set a array size and use array in a struct with a var for know how much item in array i set:
yep not optimized

typedef struct mySceneAction
{
  unsigned int id;
  unsigned int sceneId;
  unsigned int orderAction;
  unsigned int ioRemoteId;
  unsigned int ioRemoteChannel;
  unsigned int ioRemoteAction;
} mySceneAction;
typedef struct myListSceneAction
{
  unsigned int nbSceneAction; // nb action set in array
  mySceneAction sceneAction[20];
} myListSceneAction;

void sceneRun(int sceneId)
{
  myListSceneAction listSceneAction;
  if (dbLoadSceneAction(sceneId, &listSceneAction)) {
    // do something with array of data, 3 item in this sample
  }
}

int dbCountSceneAction(int sceneId)
{
  // by sql we get nb from db
  return 3; // exemple
}

bool dbLoadSceneAction(int sceneId, struct myListSceneAction *listSceneAction)
{
  // get data from db
  if (sceneId == -1) return false;

  listSceneAction->nbSceneAction = dbCountSceneAction(sceneId);
  if (listSceneAction->nbSceneAction == 0) return false;

  // get data from db in listSceneAction->sceneAction[x] so 3 item set in this sample

  return true;
}

void setup() {
}

void loop() {
  sceneRun(5);
}