Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8196387
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T05:27:31+00:00 2026-06-07T05:27:31+00:00

Say there is a source file a.c with some function func_a. I would like

  • 0

Say there is a source file a.c with some function func_a. I would like to call func_a based on some feature define and would also like a.c to be included in the module based on ideally same feature define.

so in my module source that is always present (say main.c) I could have something like

#ifdef FEATURE_A
func_a();
#endif

and in the kbuild for the module something like

obj-$(CONFIG_SAMPLE) += sample.o
sample-objs := main.o utils.o

only if FEATURE_A is defined, include a.c into the sample module

???

But this may not make sense since one is a pre-processor directive and the other a compiler/linker/build directive. Maybe the other way where the pre-processor directive uses some flag defined by the kbuild makes more sense? Is there some way to accomplish this?

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T05:27:33+00:00Added an answer on June 7, 2026 at 5:27 am

    I will answer your question by pointing out how sysctl support is conditionally included in the NFS module (I’m sure there are other examples, but this is what I’m familiar with):

    • include/linux/nfs_fs.h
    • fs/nfs/Makefile
    • fs/nfs/super.c

    The kernel config system maintains a file “include/linux/autoconf.h” that exposes your configuration options as C preprocessor macros. So the files listed above compile differently depending on whether you configured sysctl support.

    If sysctl support is enabled: The header “include/linux/nfs_fs.h” checks the macro CONFIG_SYSCTL and declares the C function nfs_register_sysctl(). This function is called in “fs/nfs/super.c”. The Makefile (seeing nfs-y += sysctl.o) directs the build system to compile in the file “fs/nfs/sysctl.c” into the module, which defines the function nfs_register_sysctl().

    If sysctl support is disabled: The header “include/linux/nfs_fs.h” checks the macro CONFIG_SYSCTL and declares the preprocessor macro nfs_register_sysctl() to be 0. This macro is used in “fs/nfs/super.c” to bypass some (dead) error-handling code. The Makefile (seeing nfs-n += sysctl.o) does not compile or link “fs/nfs/sysctl.c”.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'd like to do some stuffs before main function. I have multiple source files.
Say there are multiple requests in a integration test, some of them are local
say there is an xml file, which not created by me, with a known
Lets say there is setup like this: public class MyClass { public void DoSomething(string
Say I have a bash script file config.sh . It's meant to be source'd
Assume I have a sample source file, test.c, which I am compiling like so:
I have many source/text file, say file.cpp or file.txt . Now, I want to
I would like to compile c# source code from a string. I know this
I am trying to preprocess my C++ source files by ANTLR. I would like
Let's say you want to show the source code for a settings file but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.