LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 01-21-2013, 10:39 PM   #1
CandyRedTele
LQ Newbie
 
Registered: Jan 2013
Posts: 7

Rep: Reputation: Disabled
‘u16’ does not name a type


Hello,

I'm trying to compile a cpp file which includes ad799x.h and I get this error :

ad799x.h:121:2: error: ‘u16’ does not name a type

I would like to know what should I include or link to be able to compile?

Thanks
 
Old 01-21-2013, 11:00 PM   #2
corp769
LQ Guru
 
Registered: Apr 2005
Location: /dev/null
Posts: 5,818

Rep: Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007
In your ad799x.h file, what is on line 121? And what is the purpose of your program/what does it do? By reading the error, it seems as you don't have a function, struct, etc properly defined. Also, if you could post more information about the header file, it would definitely help in further troubleshooting.
 
Old 01-22-2013, 09:03 AM   #3
CandyRedTele
LQ Newbie
 
Registered: Jan 2013
Posts: 7

Original Poster
Rep: Reputation: Disabled
I'm trying to talk to the sensor AD7998, and to do that I'm supposed to use 'iio'.
The stucture is not defined in ad799x.h, that's why I think I have to include something else.

118
119 struct ad799x_platform_data {
120 u16 vref_mv;
121 };
122

You can find the header here :
http://wiki.analog.com/resources/too...98?force_rev=1
 
Old 01-22-2013, 09:59 AM   #4
johnsfine
LQ Guru
 
Registered: Dec 2007
Distribution: Centos
Posts: 5,286

Rep: Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197
That code in ad799x.h is clearly assuming some previous include file defined u16 to be the same as __u16

But I can't see where in that project the definition of u16 is supposed to occur.

Somewhere there ought to be lines such as
Code:
typedef __u16 u16;
typedef __u8 u8;
But I'm not sure where those should be of whether that should be done in some way with more portability protection.

Another possibility is that you are supposed to include /usr/include/op_types.h

Last edited by johnsfine; 01-22-2013 at 10:13 AM.
 
Old 01-22-2013, 10:12 AM   #5
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,862
Blog Entries: 1

Rep: Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869
Guess this source is meant for use in the kernel, where type 'u16' is defined. Try this:

Code:
#define __KERNEL__
#include <linux/types.h>
#include "ad799x.h"
 
Old 01-27-2013, 12:02 PM   #6
CandyRedTele
LQ Newbie
 
Registered: Jan 2013
Posts: 7

Original Poster
Rep: Reputation: Disabled
I tried this :

#define __KERNEL__
#include <linux/types.h>
#include "ad799x.h"

But I got the same errors.
Any idea?
 
Old 01-27-2013, 12:09 PM   #7
johnsfine
LQ Guru
 
Registered: Dec 2007
Distribution: Centos
Posts: 5,286

Rep: Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197
Maybe it varies by version, but the linux/types.h on my system does not declare u16 regardless of what #define's you might have.

The /usr/include/op_types.h does define u16 conditional on some #define.

Try looking at the .h file that you hope might solve your problem and see for yourself whether/when it declares u16
 
Old 01-27-2013, 01:00 PM   #8
CandyRedTele
LQ Newbie
 
Registered: Jan 2013
Posts: 7

Original Poster
Rep: Reputation: Disabled
// This fixe the u16 error :
#define __KERNEL__
#include <asm-generic/int-ll64.h>
#include "ad799x.h"

g++ -I/usr/src/linux-headers-3.0.0-30-generic/include test.cpp
In file included from test.cpp:4:0:
ad799x.h:97:33: erreur: field ‘channel’ has incomplete type


channel is of type iio_chan_spec which is defined here in linux/iio/iio.h
But when I include it, I get Alot of errors
 
Old 01-27-2013, 10:51 PM   #9
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,862
Blog Entries: 1

Rep: Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869
Whenever you have a pre-processor related problem, ask cpp for help:

Code:
compilation: gcc <options> -c mysource.c -o mysource.o
pre-proc:    cpp <options> -dD mysource.c mysource.E
file mysource.E will contain the preprocessor's output.
 
Old 01-28-2013, 02:54 AM   #10
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,862
Blog Entries: 1

Rep: Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869
Made a few test that confirmed my original opinion: this source is meant for use in the kernel. It heavily depends on other kernel headers, not likely to be usable from user program.
 
Old 01-28-2013, 07:13 AM   #11
mina86
Member
 
Registered: Aug 2008
Distribution: Debian
Posts: 517

Rep: Reputation: 229Reputation: 229Reputation: 229
Why are you using this header in user space? It's a kernel driver.

In general “u16” type is never declared by Linux headers included by user space and for user space use “__u16” is used instead. If you find yourself in need to define __KERNEL__ than you're most likely doing something you should not be doing (or there is a problem with the header file).

Last edited by mina86; 01-28-2013 at 07:15 AM.
 
Old 01-28-2013, 09:05 AM   #12
CandyRedTele
LQ Newbie
 
Registered: Jan 2013
Posts: 7

Original Poster
Rep: Reputation: Disabled
Ok thanks for your answers!

I'm probably doing something wrong. I thougth the driver would be the interface between the user space and the kernel. If I'm not supposed to use the driver from user space, does that mean that I have to compile a kernel module in order to be able to use the sensor AD7998? Or is there a 'normal' way to do that from user space?
 
Old 01-28-2013, 12:13 PM   #13
mina86
Member
 
Registered: Aug 2008
Distribution: Debian
Posts: 517

Rep: Reputation: 229Reputation: 229Reputation: 229
Quote:
Originally Posted by CandyRedTele View Post
I'm probably doing something wrong. I thougth the driver would be the interface between the user space and the kernel. If I'm not supposed to use the driver from user space, does that mean that I have to compile a kernel module in order to be able to use the sensor AD7998? Or is there a 'normal' way to do that from user space?
Since Linux 2.6.31 ad799x driver is in staging directory so you should use it instead of building the module itself.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
error: ‘u16’ does not name a type CandyRedTele Linux - Software 1 01-21-2013 10:37 PM
changing file system type to another filesystem type,does it effect on data? janakiramulu Ubuntu 1 02-04-2011 01:58 AM
mandriva dual boot filesystem type unknown,partition type 0x7 llearner Linux - Newbie 2 01-24-2010 02:03 PM
Dual Boot Vista Suse 10.2 error setting type of partition to type 82 jmp559 Linux - General 1 05-15-2008 06:40 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:00 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration