| | |
how to get the linux kernel version in cpp program
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Nov 2008
Posts: 13
Reputation:
Solved Threads: 0
I have a problem like i need to include a different header files depending on the linux kernel in a .cpp file. I have to check the linux kernel version and include the headerfile depending on that kernel. How can I do that?
I have ARCH variable in Makefile which gives me exactly the kernel version, can i make use of that?
I have ARCH variable in Makefile which gives me exactly the kernel version, can i make use of that?
I'm going to guess, though I've never done this myself, that you'd do that through preprocessor directives in your source code. I'm thinking it would look something like:
Of course, you'll want to change the version in KERNEL_VERSION, but beyond that it should work.
Check out this post: kernel version in C preprocessor
C++ Syntax (Toggle Plain Text)
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0) #include <whatever_header.h> #else #include <a_different_header.h> #endif
Of course, you'll want to change the version in KERNEL_VERSION, but beyond that it should work.
Check out this post: kernel version in C preprocessor
WolfWorkz Studios - Server Development
WolfWorkz.com
Pirates Registration
My Personal Blog
SideBySideGeek.com - My Newest Project
WolfWorkz.com
Pirates Registration
My Personal Blog
SideBySideGeek.com - My Newest Project
![]() |
Other Threads in the C++ Forum
- Previous Thread: Colours in Dialog boxes c++
- Next Thread: Confuse with traverse
| Thread Tools | Search this Thread |
api array based beginner binary bitmap c++ c/c++ calculator char char* class classes code compile compiler console conversion count delete deploy desktop directshow dll download dynamic dynamiccharacterarray encryption error file forms fstream function functions game givemetehcodez google graph gui homeworkhelp homeworkhelper iamthwee ifstream input int integer java lib linkedlist linker linux list loop looping loops map math matrix memory news node number numbertoword output parameter pointer problem program programming project python random read recursion recursive reference return rpg sorting string strings struct temperature template templates test text text-file tree unix url variable vector visualstudio win32 windows winsock word wordfrequency wxwidgets





