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 08-26-2011, 02:46 AM   #1
hayf
Member
 
Registered: Aug 2011
Distribution: Debian
Posts: 35

Rep: Reputation: Disabled
error: 'NET_IPV4_TCP_VAR' undeclared here (not in a function)


HI,
I am trying to add a new sysctl variable used for tcp.
So I defined the variable in sysctl.h, and in sysctl_net_ipv4.c i defined the variable in this way:

code:
{
.ctl_name = NET_IPV4_TCP_VAR,
.procname = "tcp_var",
.data = &sysctl_tcp_var,
.maxlen = sizeof(int),
.mode = 0644,
.proc_handler = &proc_dointvec
},

So when I am compiling my Kernel, i got the following error:

net/ipv4/sysctl_net_ipv4.c:193: error: 'NET_IPV4_TCP_VAR' undeclared here (not in a function)

what is problem here? Any idea?
 
Old 08-26-2011, 08:30 PM   #2
ta0kira
Senior Member
 
Registered: Sep 2004
Distribution: FreeBSD 9.1, Kubuntu 12.10
Posts: 3,078

Rep: Reputation: Disabled
You should check the #includes for both the header and the source. It's entirely possible that sysctl.h is just a wrapper for another header and that the source includes that other header directly. Also check the preprocessor conditionals in the header to make sure you didn't inadvertently put the #define within a block that doesn't get compiled.
Kevin Barry

edit: Did you modify sys/sysctl.h or linux/sysctl.h? Was it in the kernel source tree?

Last edited by ta0kira; 08-26-2011 at 08:33 PM.
 
Old 08-27-2011, 07:25 AM   #3
hayf
Member
 
Registered: Aug 2011
Distribution: Debian
Posts: 35

Original Poster
Rep: Reputation: Disabled
U r right, i ahould declare my variable in linux/sysctl.h
So kernel recompilation was successfull after i corrected my mistake.

But my new kernel variable is not working (error in my variable)
All what i did is declaring my vaiable at the end of the enum containing net_ipv4 variables such as sysctl_tcp_timestamps
Then i defined my var in sysctl_net_ipv4.c (code in first msg) and i used my var in other codes
I didnt find my varible in /etc/sysctl.conf and add to this other sysctl variables e.g. Tcp_timestamps are not working after recompilation ( they were working before)

Am i missing anything in defining my variable? What r the steps to declare sysctl varable?

Can the problem be that in sysctl.h we must give a number to the variable (in the enum) and sysctl_net_ipv4.c I must take in consideration the order to declare my var??

Thanks in advance, i hope i were enough clear in my explanation
 
Old 08-27-2011, 10:15 AM   #4
ta0kira
Senior Member
 
Registered: Sep 2004
Distribution: FreeBSD 9.1, Kubuntu 12.10
Posts: 3,078

Rep: Reputation: Disabled
I have to admit I've never added a sysctl; however, it might help if you post a userspace program that highlights the problem you're having.
Kevin Barry
 
  


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
‘PTHREAD_MUTEX_ERRORCHECK’ undeclared here (not in a function) Aquarius_Girl Programming 17 01-04-2011 08:12 PM
CONFIG_Kernel_start undeclared first use in this function Aref Linux - Kernel 0 11-22-2008 05:39 AM
error: ‘KBUILD_MODNAME’ undeclared in function ‘pci_register_driver’ amio.praba@gmail.com Linux - Embedded & Single-board computer 0 06-30-2008 02:31 AM
error: ‘LOGGING_FACILITY’ undeclared (first use in this function) nasim751 Linux - Software 1 04-19-2008 05:55 AM
undeclared here (not in a function) ashlesha Linux - Software 2 08-23-2006 11:29 PM

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

All times are GMT -5. The time now is 04:37 AM.

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