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 8398637
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T21:06:03+00:00 2026-06-09T21:06:03+00:00

I have a library as this: mylib |__ device |__ lcd.h |__ lcd_config.h |__

  • 0

I have a library as this:

mylib
  |__ device
        |__ lcd.h
        |__ lcd_config.h
        |__ lcd.c

.

// File lcd.h
#include lcd_config.h

void function initLcd();
void function writeLcd();

.

// File lcd.c
#include lcd.h

void function writeLcd(){
     // some code
}

.

// File lcd_config.h inside mylib
#ifndef lcd_config_H
#define lcd_config_H

#define TEST 10

#endif

I want to use the library in a project, but I want to redefine the configuration file.

myproject
    |__ lcd_config.h
    |__ mylcd.c
    |__ main.c

.

// File lcd_config.h inside myproject(at main.c level)
#ifndef lcd_config_H
#define lcd_config_H

#define TEST 20

#endif

.

// File mylcd.c
#include lcd.h

void function initLcd(){
     printf("%d", TEST);
}

.

// File main.c
#include "device/lcd.h"

int main(void) {
    initLcd(); // print 10
}

.

// File main1.c
#include "lcd_config.h"
#include "device/lcd.h"

int main(void) {
    initLcd(); // print 10 too
}

In my project i want that TEST = 20, how can i achieve this?

UPDATE

Look at file now, this is my real case.

To print TEST=20 i have to put #include lcd_config.h before #include lcd.h inside mylcd.c.
If i put it in main file(like main1.c) 10 will be print, s i think preprocessing look before inside mylcd.h that main.c.

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-09T21:06:04+00:00Added an answer on June 9, 2026 at 9:06 pm

    Include the header that defines the TEST to 20 first. Beware that the #ifndef conditions will prevent the second header from actually doing anything, this is why in your case the value of TEST remains 10.

    In some more detail, the block below says “this header should only be included in the project once”. Defining the second header with the same clause in it will not change things if that header is included after the first one.

    #ifndef lcd_config_H
    #define lcd_config_H
    ...
    #endif
    

    I think the whole situation looks strange, though, there shouldn’t be too headers with exactly the same name.

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

Sidebar

Related Questions

I have a library I created, File mylib.c: #include <mylib.h> int testlib() { printf("Hello,
I have enabled google Minify in code igniter using this library on our website.
I have an ActionScript 2.0 file that contains a small library. This library parses
I have a Java program making some JNI calls to a native library (mylib.so).
I have written a static library to re-use some code between iOS projects, let's
I have a file hello.c #include<stdio.h> void hello() { printf(Hello!\n); } A header hello.h
I have this library called BASS which is an audio library which I'm going
I have a library written in C++, and a wrapper for this library written
I have created a static library following this link . But I am facing
I have a library that has several options defined as this: #define shouldShowToolbar YES

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.