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



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-5.c
*/
.
.

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. I think
module_param_array() is suppose to set the num parameter to the
number of array elements the user supplied at the invocation
of insmod. So if i say:

insmod hello-5.ko myintArray = 42

and printk the arr_argc variable I should see

arr_argc = 1

by getting rid of the address operator, I believe I am ignoring num via
NULL


All the errors point to the same line (49, module_par.....).

If you go to www.tldp.org/LDP/lkmpg/2.6/html/x323.html you can see the
whole example module.


Thanks in advance

.



Relevant Pages

  • Re: invalid lvalue in unary & ... why? LKM
    ... > initializer element is not constant ... > If I get rid of the address operator it will compile, ... > module_param_arrayis suppose to set the num parameter to the ... > by getting rid of the address operator, I believe I am ignoring num via ...
    (comp.os.linux.development.system)
  • Re: invalid lvalue in unary & .... why LKM
    ... bob wrote: ... If I get rid of the address operator it will compile, ...
    (comp.lang.c)
  • Re: Microsoft has done it again...
    ... DWORD dwGITCookie = ); ... And to get rid of the warnings disable 64-bit portablility issues. ... This compile cleanly, does anyone have any suggestions on how to resolve ...
    (microsoft.public.vc.atl)
  • Re: FreeBSD 5.1-R kernel panic
    ... > will see the same panic Stephane saw. ... > to compile a new kernel that does not have the USB stuff compiled in, ... Does reverting to pre-July 20 get rid of your problem? ...
    (freebsd-current)
  • Re: problem compiling related to extern
    ... > extern FILE *DFILE; ... > I think the mysterious "initializer element" error is related to ... > If I remove this bit I can get the program to compile (but it ... > What is the proper way to initialize the pointer *DFILE to be stderr? ...
    (comp.lang.c)