Help "error: dereferencing pointer to incomplete type"

  • (2 Pages)
  • +
  • 1
  • 2

15 Replies - 3036 Views - Last Post: 22 September 2014 - 08:03 PM Rate Topic: -----

#1 Freewaymad   User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 24
  • Joined: 06-September 14

Help "error: dereferencing pointer to incomplete type"

Posted 13 September 2014 - 06:33 PM

Hi,

I am getting this error:

drivers/media/video/mxc/capture/gt2005.c:2256:62: error: dereferencing pointer to incomplete type

I am at a loss trying to figure this out. Here it is:
		case Sensor_Flash:
		{
			struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
    		struct sensor *sensor = to_sensor(client);

			if (sensor->sensor_io_request && sensor->sensor_io_request->sensor_ioctrl) {
				sensor->sensor_io_request->sensor_ioctrl(icd->pdev,Cam_Flash, on);
                if(on){

Lines 6 and 7 are giving me the same error. What am I doing wrong? Hopefully someone can point me in the right direction. Please help. Thanks,

Is This A Good Question/Topic? 0
  • +

Replies To: Help "error: dereferencing pointer to incomplete type"

#2 sepp2k   User is offline

  • D.I.C Lover
  • member icon

Reputation: 2770
  • View blog
  • Posts: 4,429
  • Joined: 21-June 11

Re: Help "error: dereferencing pointer to incomplete type"

Posted 13 September 2014 - 07:01 PM

The error means that no definition of the struct sensor is in scope when you try to dereference the pointer. You probably forgot to #include whichever header defines the struct.
Was This Post Helpful? 0
  • +
  • -

#3 jimblumberg   User is offline

  • member icon

Reputation: 5916
  • View blog
  • Posts: 17,932
  • Joined: 25-December 09

Re: Help "error: dereferencing pointer to incomplete type"

Posted 13 September 2014 - 07:03 PM

Without knowing how the various variables are defined it is almost impossible to tell where or what the actual problem is. I suggest you break apart your if statement into smaller pieces and see if you can deduce the problem. For example try printing, on a separate line, sensor->sensor_io_request, the next variable, and the next all on individual lines. But one thing I notice is that in the if statement sensor_ioctrl seems to be a variable but in the body of the if statement it seems to be a function. Which is correct? Is it a function or is it a variable?


Jim
Was This Post Helpful? 0
  • +
  • -

#4 Freewaymad   User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 24
  • Joined: 06-September 14

Re: Help "error: dereferencing pointer to incomplete type"

Posted 13 September 2014 - 07:11 PM

View Postjimblumberg, on 13 September 2014 - 07:03 PM, said:

Without knowing how the various variables are defined it is almost impossible to tell where or what the actual problem is. I suggest you break apart your if statement into smaller pieces and see if you can deduce the problem. For example try printing, on a separate line, sensor->sensor_io_request, the next variable, and the next all on individual lines. But one thing I notice is that in the if statement sensor_ioctrl seems to be a variable but in the body of the if statement it seems to be a function. Which is correct? Is it a function or is it a variable?


Jim

It is a function.
Was This Post Helpful? 0
  • +
  • -

#5 Freewaymad   User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 24
  • Joined: 06-September 14

Re: Help "error: dereferencing pointer to incomplete type"

Posted 14 September 2014 - 05:51 PM

I have identified this as the culprit:
sensor->sensor_io_request->sensor_ioctrl

I know it has something to do with my fsl_camera.h file (attached) which goes along with what sepp2k said:

Quote

The error means that no definition of the struct sensor is in scope when you try to dereference the pointer. You probably forgot to #include whichever header defines the struct.
I am still at a loss trying to fix this. Please point me in the right direction. The light bulb has not come. Please help.

Attached File(s)


Was This Post Helpful? 0
  • +
  • -

#6 infernorthor   User is offline

  • D.I.C Lover

Reputation: 362
  • View blog
  • Posts: 1,718
  • Joined: 07-February 14

Re: Help "error: dereferencing pointer to incomplete type"

Posted 14 September 2014 - 06:22 PM

I feel like we've been down this road before. I'm not trying to be mean, but I think you should work on a simpler project without libraries. Make sure you understand functions, pointers, structs. In all their forms.
Knowing that will greatly help debugging. The syntax tells you a lot about what you need to do. Then you read the manual for the library to figure solutions. Such as calling a certain function before you use a pointer.

Because if sensor_ioctrl is a function, it should always look like a function in syntax.
And embedding a function inside two pointers to structs seems bizarre.
But, if you understand pointer you check to make sure they are properly being created, by reading the manual.
Was This Post Helpful? 1
  • +
  • -

#7 Freewaymad   User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 24
  • Joined: 06-September 14

Re: Help "error: dereferencing pointer to incomplete type"

Posted 14 September 2014 - 06:56 PM

I do agree with you and get what you are saying. This all came about, over a year ago, trying to get the source code for an android device. The code is "GPL'ed", but the company I have requested the code from does not seem to understand what "GPL" is. They are supposed to supply the source code if requested. Long story short, here I am. I am down to these last six errors which are all of this type for this camera driver. I am hoping someone with some patience could help me through this. Do not get me wrong, I do not need someone to do the work for me. I just need some guidance and help, please. Maybe, just maybe, I can learn something new. Believe me, this whole thing has been a learning experience.
Was This Post Helpful? 0
  • +
  • -

#8 infernorthor   User is offline

  • D.I.C Lover

Reputation: 362
  • View blog
  • Posts: 1,718
  • Joined: 07-February 14

Re: Help "error: dereferencing pointer to incomplete type"

Posted 14 September 2014 - 07:31 PM

Well the header you provided is insufficient. Also, sensor_ioctrl is the name of a function pointer, but to a different struct.
Using on, that is the name of the variable.

These are major issues, that I don't think you know what you are doing. If you are just trying to fudge a bunch of code snippets from the internet I don't think you will get it working. And we aren't going to learn and explain the much of library.
Was This Post Helpful? 0
  • +
  • -

#9 jimblumberg   User is offline

  • member icon

Reputation: 5916
  • View blog
  • Posts: 17,932
  • Joined: 25-December 09

Re: Help "error: dereferencing pointer to incomplete type"

Posted 14 September 2014 - 07:33 PM

View PostFreewaymad, on 14 September 2014 - 07:51 PM, said:

I have identified this as the culprit:
sensor->sensor_io_request->sensor_ioctrl

I know it has something to do with my fsl_camera.h file (attached) which goes along with what sepp2k said:

Quote

The error means that no definition of the struct sensor is in scope when you try to dereference the pointer. You probably forgot to #include whichever header defines the struct.
I am still at a loss trying to fix this. Please point me in the right direction. The light bulb has not come. Please help.

Well you said that sensor_ioctrl was a function not a variable so is the above line the way you call a function? Answer no.

Look at the line directly below the line containing that code, do you see a difference?

Jim
Was This Post Helpful? 0
  • +
  • -

#10 Freewaymad   User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 24
  • Joined: 06-September 14

Re: Help "error: dereferencing pointer to incomplete type"

Posted 14 September 2014 - 08:02 PM

I have obtained this, obviously, on the internet from other tablet manufacturers. I have compared this to a lot of other camera drivers (mostly Rockchip) and this is the way the Chinese seem to have these written on working tablets. These are not just a bunch of snippets from here and there. A lot of the android camera drivers are almost the same; based on the MT9M001 CMOS Image Sensor from Micron (basically used as a template). Anyway I will keep on working on it and one way or another get it figured out. Thank you for the replies.
Was This Post Helpful? 0
  • +
  • -

#11 #define   User is offline

  • Cannot compute!
  • member icon

Reputation: 1868
  • View blog
  • Posts: 6,763
  • Joined: 19-February 09

Re: Help "error: dereferencing pointer to incomplete type"

Posted 14 September 2014 - 08:31 PM

Hi, I'm not keen on the variable sensor having the same name as a type albeit a struct.

Yes, sensor_ioctrl is a function pointer and so is a variable.

I don't see where you have given us the ic2_client and sensor declarations, I can only guess at the problem. Here is one guess.

Dereferencing pointer to incomplete type
Was This Post Helpful? 0
  • +
  • -

#12 Freewaymad   User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 24
  • Joined: 06-September 14

Re: Help "error: dereferencing pointer to incomplete type"

Posted 15 September 2014 - 05:55 PM

View Post#define, on 14 September 2014 - 08:31 PM, said:

Hi, I'm not keen on the variable sensor having the same name as a type albeit a struct.

Yes, sensor_ioctrl is a function pointer and so is a variable.

I don't see where you have given us the ic2_client and sensor declarations, I can only guess at the problem. Here is one guess.

Dereferencing pointer to incomplete type

Thanks. I will have to check out the link. I have attached the the driver and my log, if you are interested in taking a look at it (do not be alarmed it being over 3000 lines). Thanks again.

Attached File(s)


This post has been edited by Freewaymad: 15 September 2014 - 06:02 PM

Was This Post Helpful? 0
  • +
  • -

#13 Freewaymad   User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 24
  • Joined: 06-September 14

Re: Help "error: dereferencing pointer to incomplete type"

Posted 21 September 2014 - 11:30 AM

View Post#define, on 14 September 2014 - 08:31 PM, said:

Hi, I'm not keen on the variable sensor having the same name as a type albeit a struct.

Yes, sensor_ioctrl is a function pointer and so is a variable.

I don't see where you have given us the ic2_client and sensor declarations, I can only guess at the problem. Here is one guess.

Dereferencing pointer to incomplete type

Thanks again #define. I looked into the link you gave me, but no joy. I still think it goes back to what sepp2k said

Quote

The error means that no definition of the struct sensor is in scope when you try to dereference the pointer. You probably forgot to #include whichever header defines the struct.

I am looking into the ic2_client and sensor declarations.
Was This Post Helpful? 0
  • +
  • -

#14 #define   User is offline

  • Cannot compute!
  • member icon

Reputation: 1868
  • View blog
  • Posts: 6,763
  • Joined: 19-February 09

Re: Help "error: dereferencing pointer to incomplete type"

Posted 22 September 2014 - 01:23 PM

Hi, yep the errors are at line 2257. The struct sensor definition is at line 2027 which is before the error and ok. The member pointer sensor_io_request is of type struct gt2005camera_platform_data.

The struct gt2005camera_platform_data is not defined in the file.

So have a look for that structure.
Was This Post Helpful? 1
  • +
  • -

#15 Freewaymad   User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 24
  • Joined: 06-September 14

Re: Help "error: dereferencing pointer to incomplete type"

Posted 22 September 2014 - 07:06 PM

View Post#define, on 22 September 2014 - 01:23 PM, said:

Hi, yep the errors are at line 2257. The struct sensor definition is at line 2027 which is before the error and ok. The member pointer sensor_io_request is of type struct gt2005camera_platform_data.

The struct gt2005camera_platform_data is not defined in the file.

So have a look for that structure.

Thank you so much! You are right on! I totally missed it. What I did. I changed lines (it was actually) 2036 and 2037 from this:
	struct gt2005camera_platform_data *sensor_io_request;
    struct gt2005camera_gpio_res *sensor_gpio_res;

to this:
	struct imxcamera_platform_data *sensor_io_request;
    struct imxcamera_gpio_res *sensor_gpio_res;

This now matches what I have in my "fsl_camera.h". I had the same thing at lines 3560 and 3566 which was giving me four more errors and I now the errors are fixed. Thanks again.
Was This Post Helpful? 1
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2