2-Dimensions Array as a parameter - Suspicious pointer conversion

General discussion on mikroC PRO for PIC.
Post Reply
Author
Message
renew
Posts: 28
Joined: 24 Nov 2016 13:56

2-Dimensions Array as a parameter - Suspicious pointer conversion

#1 Post by renew » 03 Feb 2023 04:51

Hi, folks
I have a 2 dimensions array like this

Code: Select all

const char sound_menu[3] [13] = {
   {"SOUND + VIBR"},
   {"   SOUND    "},
   {" VIBRATION  "}
   };
When i transfer the second dimension into function

Code: Select all

Write_String(62, 7, sound_menu[sound_menu_index]);
I obtain this message
308 1505 Suspicious pointer conversion main.c
I tried to use pointers but every time I got some kind messages or errors. Not enough knoweleges.
Please help.

Function prototype:

Code: Select all

void Write_String(unsigned char xposition, unsigned char yposition, char *);
void Write_String(char xposition, char yposition, char *string){
............

User avatar
Tanja_Kovacevic
mikroElektronika team
Posts: 98
Joined: 09 Aug 2021 11:39

Re: 2-Dimensions Array as a parameter - Suspicious pointer conversion

#2 Post by Tanja_Kovacevic » 03 Feb 2023 11:09

Hi,

You can omit one dimension but in that case, empty parentheses are necessary.

In the Help section of your compiler you can see this example:
arrays.JPG
arrays.JPG (88.75 KiB) Viewed 980 times

Kind regards,
Tanja

renew
Posts: 28
Joined: 24 Nov 2016 13:56

Re: 2-Dimensions Array as a parameter - Suspicious pointer conversion

#3 Post by renew » 03 Feb 2023 13:21

Thank you for the reply
I can't omit some some dimesion because I transfer all the first dimension as a string so I must to show second dimension

I tried this

Code: Select all

Write_String(62, 7, sound_menu[sound_menu_index][]);
Result
308 315 Invalid expression main.c

User avatar
Tanja_Kovacevic
mikroElektronika team
Posts: 98
Joined: 09 Aug 2021 11:39

Re: 2-Dimensions Array as a parameter - Suspicious pointer conversion

#4 Post by Tanja_Kovacevic » 09 Feb 2023 12:10

Hi,

You can not omit dimensions in the function call.

Here is one way to use a multi-dimensional array:

m_array.JPG
m_array.JPG (212.55 KiB) Viewed 935 times

You can use this function declaration as well:
void Write_String(unsigned char xposition, unsigned char yposition, char* string)


Kind regards,
Tanja

renew
Posts: 28
Joined: 24 Nov 2016 13:56

Re: 2-Dimensions Array as a parameter - Suspicious pointer conversion

#5 Post by renew » 12 Mar 2023 21:31

Hi.
Sorry for the late answer.
In this case we have
1508 Implicit conversion of int to ptr main.c

Your example has the same error.

frank.malik
Posts: 96
Joined: 09 Apr 2021 20:37

Re: 2-Dimensions Array as a parameter - Suspicious pointer conversion

#6 Post by frank.malik » 13 Mar 2023 14:45

Hi,

I tried it with NECTO Studio and the PIC32 AI Compiler. So the results might be a little bit different.
First, I would suggest to use pointer to string like this

Code: Select all

char *sound_menu[] = {
    "SOUND + VIBR",
    "   SOUND    ",
    " VIBRATION  "
} ;
The call might be change to this

Code: Select all

Write_String(62, 7, sound_menu[sound_menu_index]);
Function prototype like this

Code: Select all

void Write_String(char xposition, char yposition, char *string) ;
I got no error messages or warning, but haven't tested if it is functional ok.
Kind regards
Frank

Fusion for STM32 v8, STM32F407ZG@168MHz, 4" TFT capacitive
mikromedia 3, PIC32MZ2048EFH100@200MHz, 3" TFT capacitive
NECTO Studio 3.0.0, mikroC AI for ARM/PIC32, mikroSDK v.2.7.2

renew
Posts: 28
Joined: 24 Nov 2016 13:56

Re: 2-Dimensions Array as a parameter - Suspicious pointer conversion

#7 Post by renew » 13 Mar 2023 22:32

Hi
Thanks, it works
but still
204 1505 Suspicious pointer conversion main.c
there.

Post Reply

Return to “mikroC PRO for PIC General”