Find the answer to your Linux question:
Results 1 to 3 of 3
dear frens, i am in delima so if somecan help please do i gonna be dead soon what are these lines of codes do in c programming? 1) #if defined(CONFIG_SMP) ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Jun 2005
    Location
    Nepal
    Posts
    3

    Confusion with device driver programming.


    dear frens,
    i am in delima
    so if somecan help please do
    i gonna be dead soon
    what are these lines of codes do in c programming?

    1)
    #if defined(CONFIG_SMP)
    #define MODEVERSIONS
    #include <linux/modeversions.h>
    #endif

    2)
    static struct file_operations schar_fops={
    read: schar_read,
    write: schar_write,
    };

    can anyone explain this to me? I would be grateful if you provide some useful links too.
    thanking in advance

  2. #2
    Linux User
    Join Date
    Oct 2004
    Location
    /dev/random
    Posts
    404
    1.
    This is an example of conditional compilation.

    The code (the C preprocessor, to be precise) first checks if the macro CONFIG_SMP is defined. If it is defined, then it will go onto executing the following instructions, otherwise they will not be executed. It's much like regular if(){....} block in C, but it is processed by the preprocessor.

    So, in this case, if CONFIG_SMP is defined, then the preprocessor will define a macro MODVERSIONS and include linux/modversions.h

    2. It defines an object of the type struct file_operations.
    It uses the GNU extension of tagged initialization to C structures.
    Look under the section of "File Operations" in the following article:
    http://lwn.net/Kernel/LDD2/ch03.lwn
    The Unforgiven
    Registered Linux User #358564

  3. #3
    Just Joined!
    Join Date
    Jun 2005
    Location
    Nepal
    Posts
    3

    Thanks

    Thanks a lot........

    I will be seeking details, so please forward me any links if you have some..


    Thanks again.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •