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

B

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;
.
.
.
/*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.....).

Thanks in advance
 
I

Ian Collins

bob said:
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?
 
K

Keith Thompson

bob said:
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.
 
G

Grumble

bob said:
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
 
S

SM Ryan

# 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).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,954
Messages
2,570,116
Members
46,704
Latest member
BernadineF

Latest Threads

Top