Array lenght

General discussion on mikroBasic PRO for ARM.
Post Reply
Author
Message
joro800
Posts: 12
Joined: 19 Dec 2015 14:57

Array lenght

#1 Post by joro800 » 08 Feb 2018 12:52

I'm trying to count array lenght in bytes through function pointer, from address of first elemet to boundary (sizeof not work for me), but boundary is 32bit aligned, and mistake is from 0 to 3 bytes. Any ideas for better solution? Tnx.

mcumake
Posts: 136
Joined: 07 Jun 2016 12:16

Re: Array lenght

#2 Post by mcumake » 18 Mar 2018 19:46

Hi try this macro

#define NELEMS(x) (sizeof(x) / sizeof((x)[0]))


example :

int arra[17] ;
int n = NELEMS(arra) ;

Post Reply

Return to “mikroBasic PRO for ARM General”