CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Casting void pointer: a numeric expression must appear here

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
nickdc



Joined: 19 Sep 2018
Posts: 15

View user's profile Send private message

Casting void pointer: a numeric expression must appear here
PostPosted: Sat Nov 17, 2018 6:53 am     Reply with quote

I use a PIC18F47K42 and the CCS compiler v5.081. I'm in the process of porting the following code from XC8 to CCS.

https://www.studentcompanion.co.za/interfacing-sd-card-with-pic-microcontroller-xc8/

I get an error in the function 'validate', which I'm unable to resolve:

Code:


static
FRESULT validate (   /* FR_OK(0): The object is valid, !=0: Invalid */
   void* obj      /* Pointer to the object FIL/DIR to check validity */
)
{
   FIL *fil;
           
    fil = (FIL *) obj;   /* Assuming offset of .fs and .id in the FIL/DIR structure is identical */

   ...

}


The error message on the casting line "A numeric expression must appear here."

So I'm casting a void pointer to a FIL* pointer.

FIL is declared as follows:

Code:

typedef struct {
   FATFS*   fs;            /* Pointer to the related file system object (**do not change order**) */
   WORD   id;            /* Owner file system mount ID (**do not change order**) */
   blabla   flag;         /* Status flags */
   blabla   err;         /* Abort flag (error code) */
   DWORD   fptr;         /* File read/write pointer (Zeroed on file open) */
   DWORD   fsize;         /* File size */
   DWORD   sclust;         /* File start cluster (0:no cluster chain, always 0 when fsize is 0) */
   DWORD   clust;         /* Current cluster of fpter (not valid when fprt is 0) */
   DWORD   dsect;         /* Sector number appearing in buf[] (0:invalid) */
#if !_FS_READONLY
   DWORD   dir_sect;      /* Sector number containing the directory entry */
   blabla*   dir_ptr;      /* Pointer to the directory entry in the win[] */
#endif
#if _USE_FASTSEEK
   DWORD*   cltbl;         /* Pointer to the cluster link map table (Nulled on file open) */
#endif
#if _FS_LOCK
   UINT   lockid;         /* File lock ID origin from 1 (index of file semaphore table Files[]) */
#endif
#if !_FS_TINY
   blabla   buf[_MAX_SS];   /* File private data read/write window */
#endif
} FIL;


Where is my mistake?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sat Nov 17, 2018 10:58 am     Reply with quote

nickdc wrote:

"a numeric expression must appear here"
Where is my mistake?

I get the error on this line:
Quote:
static FRESULT validate

Reason: You don't have FRESULT defined.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Nov 18, 2018 2:39 pm     Reply with quote

There is another reason.

You have two variables with the same name FIL and fil. This is not good.
CCS is not case sensitive by default. To fix this, add #case near the top
of your program. Example:
Quote:

#include <18F46K22.h>
#fuses INTRC_IO, NOWDT
#use delay(clock=4M)
#use rs232(UART1, baud=9600, ERRORS)

#case


void main()
{

nickdc



Joined: 19 Sep 2018
Posts: 15

View user's profile Send private message

PostPosted: Mon Nov 19, 2018 12:03 pm     Reply with quote

Thanks. The #case was indeed the cause of the problem.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group