invalid initialization type; found `int' expected `pointer to int'

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

Hello!!

   

I need to initialize a pointer but getting errors as invalid initialization type.

   

Using Image Craft compiler[PSoC Designer 5.4], PSOC1.

   

Problem initializing the variable with unsigned/signed int.

   

Thank you.

0 Likes
8 Replies
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Would be much easier if you provide us with a project archive so that we can have a look at all of your code and settings.

   

Use Designer -> File -> Archive Project...

   

 

   

Bob

0 Likes
Anonymous
Not applicable

Thank you both.

   

Trying to attach the project file[notepad format], to resolve the issue.

   

But the errors are displaying like below:

   

Error message

   

The specified file 210715.rar could not be uploaded. Only files with the following extensions are allowed: doc pdf zip cycomp xls rtf txt docx xlsx pptx ppt png jpg jpeg gif.

   

Error message

   

The specified file main.c could not be uploaded. Only files with the following extensions are allowed: doc pdf zip cycomp xls rtf txt docx xlsx pptx ppt png jpg jpeg gif.

0 Likes
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

Compiler is telling you that you passed an integer vs a pointer, eg. an address.

   

 

   

For example, if my function wants a pointer, and I declare

   

 

   

uint myray[12];

   

 

   

Then you can call afunc( myray ) or afunc( &myray[0] ) but if you

   

did afunc( myray[0] ) then you would violate the afunc calling parameters

   

because you passed it an int rather than an address, a pointer.

   

 

   

Regards, Dana.

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

When you follow my advices the archive will be a .zip-file which you may upload.

   

Did you already try a type cast?

   

 

   

Bob

0 Likes
lock attach
Attachments are accessible only for community members.
Anonymous
Not applicable

Yes sir sorry I had made an RAR file now uploaded the part of the code in zip format.

   

No I have not tried type casting.

0 Likes
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

I filed a complaint with forum moderator on inability to upload .RAR files.

   

Its a standard in many parts of the world, so should be allowed.

   

 

   

You can always upload a .rar by renaming it to .txt and telling end user to rename it back.

   

More than one way to skin a cat.

   

 

   

Regards, Dana.

0 Likes
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

I looked at you code, since it is a fragment I am not sure what's going on.

   

 

   

I looked at GNU reserved words, p is not as far as I can find.

   

 

   

Should this -

   

unsigned int *p[] = {7,8,9,11,13,15,18,22,26,32,39,47,58,71,85,103};

   

 

   

be typed as this -

   

unsigned int p[ 16 ] = {7,8,9,11,13,15,18,22,26,32,39,47,58,71,85,103};

   

 

   

 

   

Regards, Dana.

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Yes, as I thought:

   

int * p = (int *)7; // Assigns 7 to the pointer p

   

This should be syntactically correct. For your case you'll have to precede each value with the type cast (int *)

   

 

   

Bob

0 Likes