473,395 Members | 1,422 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

invalid lvalue in unary '&' .... why LKM

bob
I have little C experience and am concurrently trying to tackle C and
LKM's (a little too ambitious maybe) anyway here is the problem I'm
having with an example module I found.

static int myintArray[2] = { -1, -1 };
static int arr_argc = 0;
Jan 26 '06 #1
4 6179
bob wrote:

When I compile I get this error : invalid lvalue in unary '&'
initializer element is
not constant
(near initialization for
'__param_arr_myintArray.num')

If I get rid of the address operator it will compile, but this doesn't
seem right - as in how the macro was designed to work. All the errors
point to the same line (49, module_par.....).

Can you post the macro and the struct __param_arr_myintArray?

--
Ian Collins.
Jan 26 '06 #2
"bob" <op******@hotmail.com> writes:
I have little C experience and am concurrently trying to tackle C and
LKM's (a little too ambitious maybe) anyway here is the problem I'm
having with an example module I found.
I presume LKM doesn't refer to the League of Kansas Municipalities.

I'm guessing it refers to Linux Loadable Kernel Modules, but I don't
know anything about them -- and you shouldn't expect anyone else here
to know about them either.
static int myintArray[2] = { -1, -1 };
static int arr_argc = 0;
.
.
.
/*module _param_array(name, type, num, perm);
*the first argument in the arrays name
* the second argument is the arrays data type
* The third argument is a pointer to the variable that will
store the number
* of elements of the array initialized by the user at module
loading time
*the fourth argument is the permission bits
*/

module_param_array(myintArray, int, &arr_argc, 0000);
MODULE_PARM_DESC(myintArray, "an array of integers");
When I compile I get this error : invalid lvalue in unary '&'
initializer element is
not constant
(near initialization for
'__param_arr_myintArray.num')

If I get rid of the address operator it will compile, but this doesn't
seem right - as in how the macro was designed to work. All the errors
point to the same line (49, module_par.....).


I can only guess that module_param_array is a macro, and that it
expands to an initializer or something that includes an initializer.
Without knowing what the macro definition is, I can't guess what it
expects as arguments.

There are a large number of newsgroups with "linux" in their names,
and several with both "linux" and "kernel". If I've guess right about
what you're trying to do, you should post in one of those newsgroups.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Jan 26 '06 #3
bob wrote:
I have little C experience and am concurrently trying to tackle C and
LKM's (a little too ambitious maybe) anyway here is the problem I'm
having with an example module I found.


Hello Bob,

Try asking in comp.os.linux.development.system
Jan 26 '06 #4

# module_param_array(myintArray, int, &arr_argc, 0000);
^^^

Looks like module_param_array is a #define not a function, so
you have to look at what it is expanding too. You can look up
the #define; also some compilers allow you see the text after
the preprocessor is run (such as cc -E).

--
SM Ryan http://www.rawbw.com/~wyrmwif/
OOOOOOOOOO! NAVY SEALS!
Jan 26 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: Stub | last post by:
The following code gives error C2105: '++' needs l-value. char buf; buf++ = 'A';//buf++ isn't a lvalue Why buf++ isn't a lvalue? Is this according to C Standard or is there some reason for...
19
by: Lucas Machado | last post by:
i'm doing some Linux Kernel hacking for a course i'm currently taking. there is a pointer to a struct (struct example_struct *ex_ptr) in a .c that i want to access in a system call. i defined a...
9
by: Kavya | last post by:
These were the questions asked to me by my friend 1. Operator which may require an lvalue operand, yet yield an rvalue. 2. Operator which may require an rvalue operand, yet yield an lvalue. ...
10
by: the_init | last post by:
Hi friends, I read about Lvalue in previous posting and Googled it but I'm not understood it completely. There is a small doubt. int a; a=20; // here a is Lvalue But
14
by: nobrow | last post by:
Yes I know what lvalue means, but what I want to ask you guys about is what are all valid lvalues ... a *a a *(a + 1) .... What else?
3
by: Suyash Upadhyay | last post by:
Hello all, I was writing a code regarding offset of structure elements. struct a { struct b { int i; float f; char ch; }x;
16
by: lovecreatesbea... | last post by:
K&R2, both sec A7.3.4 Postfix Incrementation and secA.7.4.1 Prefix Incrementation Operators say that "The result is not an lvalue". Is this correct? I don't see an errata on these points. If below...
33
by: Pietro Cerutti | last post by:
Hi group, assume the following declarations: char *func_1(void); void func_2(char **); I am allowed to do: char *c = func_1();
2
by: Chad | last post by:
The following question actually stems from an old Chris Torek post. And I quote from the following old CLC url ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.