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

  • Home
  • SEARCH
  • 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 3393784
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T04:05:32+00:00 2026-05-18T04:05:32+00:00

Yes, this question has been asked many times, and I’ve been looking and reading

  • 0

Yes, this question has been asked many times, and I’ve been looking and reading forums, and SO posts, but the answers are all unrelated (or so they seem) to this one. So, I have this main file :

— sgbd_server.c —

#include "sgbd_server.h"

/**
 * Open server pipe and return handle. -1 = error
 */
int open_server_pipe() {
    return pipe_open(FIFO_NAME, O_RDONLY, S_CON_COLOR);
}

/**
 * Close server pipe
 */
void close_server_pipe(int fd) {
    pipe_close(fd, FIFO_NAME, S_CON_COLOR);
}


int main(int argc, char *argv[]) {
    int pipe_fd;
    pipe_fd = open_server_pipe();

    if (pipe_fd == -1) {
        perror("Cannot open pipe");
    }

    close_server_pipe(pipe_fd); 

    exit(EXIT_SUCCESS);
}

Then the header files :

— sgbd_server.h —

#include "common.h"

#define FIFO_NAME "./sgbd_server_pipe"
#define BUFFER_SIZE PIPE_BUF

#define S_CON_COLOR 1   /* C_COLOR_RED */

— common.h —

#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <fcntl.h>
#include <limits.h>
#include <sys/types.h>
#include <sys/stat.h>

#include "console.h"

#define CLIENT_FIFO_PREFIX = "./sgbd_client_"

int pipe_open(char *f, int mode, int color);

void pipe_close(int pipe_fd, char *f, int color);

The two functions pipe_open and pipe_close are defined in pipe.c and are basically returning 0 and void. This last file is compiled separately in the Make file.

I’m not a guru at making Make files, but for the sake of this question, here it is :

SERVER    = sgbd_server
CLIENT    = sgbd_client

CC        = gcc
C_FLAGS   = -Wall -I.
LINKER    = gcc
L_FLAGS   = -Wall -l pthread -Wall -I.

RM        = rm -f


client: sgbd_client.o pipe.o console.o
    @echo -n "Building client... "
    @$(LINKER) $(L_FLAGS) -o $(CLIENT) sgbd_client.o pipe.o console.o
    @echo "Complete!\n"

server: sgbd_server.o pipe.o console.o
    @echo -n "Building server... "
    @$(LINKER) $(L_FLAGS) -o $(SERVER) sgbd_server.o pipe.o console.o
    @echo "Complete!\n"

sgbd_client.o: sgbd_client.c
    @echo -n "Refreshing client sources... "
    @$(CC) $(C_FLAGS) -c sgbd_client.c
    @echo "Done!"

sgbd_server.o: sgbd_server.c common.h
    @echo -n "Refreshing server sources..."
    @$(CC) $(C_FLAGS) -c sgbd_server.c common.h
    @echo "Done!"

pipe.o: pipe.c
    @echo -n "Refreshing pipe sources..."
    @$(CC) $(C_FLAGS) -c pipe.c
    @echo "Done!"

console.o: console.c
    @echo -n "Refreshing console sources..."
    @$(CC) $(C_FLAGS) -c console.c
    @echo "Done!"

clean:
    @echo -n "Cleaning up executables and object files... "
    @$(RM) $(SERVER) $(CLIENT) *.o
    @echo "Ok\n"

** NOTE ** : the file console.c and implements some functions to control I/O on the console, nothing fancy. As you see, it is also compiled separately.

Now, when I type make client, all is well and birds are signing, etc. etc. But when I type make server, it spits out

sgbd_server.c: In function ‘open_server_pipe’:
sgbd_server.c:7: warning: implicit declaration of function ‘pipe_open’
sgbd_server.c: In function ‘close_server_pipe’:
sgbd_server.c:14: warning: implicit declaration of function ‘pipe_close’

I’m running GCC on a Linux amd64 if it makes any difference (I doubt it).

Now, why would it warn me about that? The two functions are declared in common.h, which is included in sgbd_server.h… What am I missing here?

Thank you for your time!

** UPDATE **

Thank you everyone for your suggestion. I did try to find if there would be a file common.h somewhere else in my include path that would be included somehow… While I failed to find any that would have slipped in the compilation process instead of the local common.h (sig) I found some .ghc files sitting in my source folder. Since they are not cleaned by make clean, I deleted manually those files. Guess what? No warning. What are those files and why are they created?

  • 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-05-18T04:05:32+00:00Added an answer on May 18, 2026 at 4:05 am

    For a start, I don’t think it’s a good idea to be giving common.h to the compiler in the makefile:

    @$(CC) $(C_FLAGS) -c sgbd_server.c common.h
    

    This would be better as just:

    @$(CC) $(C_FLAGS) -c sgbd_server.c
    

    Header files are usually incorporated with just an #include. You appear to be telling the compiler to try and compile common.h as a standalone C file. That’s one difference between the client and server compile commands and you should fix it.

    The only other thing I can suggest is that you may not be getting the header files you think you’re getting. Start by putting the line:

    #error Urk! in common.h
    

    at the top of your common.h and ensure the build fails there.

    If not, then that file is coming from somewhere else. You may also want to do the same thing with your sgbd_server.h file as well.


    Based on your edit:

    I found some .ghc files sitting in my source folder. Since they are not cleaned by make clean, I deleted manually those files. Guess what? No warning. What are those files and why are they created?

    These are, assuming ghc was a typo and you meant gch, pre-compiled headers generated by gcc, at least in part to speed up the compilation process. Rather than having to process a header file many times during a build (once per source file that includes it), pre-compiling it once and using the pre-compiled version is a lot more efficient.

    I think this was most likely cause by the fact that you included common.h on your compiler command line when you did the server. By default, header files given directly to gcc will be turned into pre-compiled header files and used in preference after that point. To test this, I created a qq.h file and executed gcc qq.h and out popped qq.h.gch.

    It’s quite likely, given that deleting them solved your problem, that these files were somehow causing your issues (be that the presence of pre-compiled headers older than the real headers or something else entirely). There’s a good chance that your compile line:

    @$(CC) $(C_FLAGS) -c sgbd_server.c common.h
    

    would first compile the server program, including the old precompiled header, then make a new precompiled header out of the newer header file.

    That’s probably why a change to common.h had no (immediate) effect. You would have to make ; touch common.h ; make to ensure the newer pre-compiled header file was used in the server program.

    Whether you want to track it back to the root cause and get a proper explanation is a matter of taste – there’s a school of thought that you should sometimes just record how you fixed it and not worry too much, lest you become entangled in the very nature of reality itself.

    Not me of course, I’m the personality type that will attempt to track my problems back to the individual sub-atomic particle that caused it, but sometimes pragmatism requires me to let it go 🙂

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

Sidebar

Related Questions

First, yes I know about this question , but I'm looking for a bit
When I asked this question I got almost always a definite yes you should
I have a generic method with this (dummy) code (yes I'm aware IList has
I need a quick yes/no answer on this... Is it possible to get a
rbnResubmission.Items.FindByValue(Yes).Attributes.Add(onclick, getCheckedRadioFieldResubmission(this)); rbnResubmission.Items.FindByValue(No).Attributes.Add(onclick, getCheckedRadioFieldResubmission(this)); So I have these click events for showing rows in
I'm currently displaying a UIViewController like this: [[self navigationController] presentModalViewController:modalViewController animated:YES]; and hiding it
I'm trying to display a table full of twitter statuses (yes, this is the
I'm working with a large (270+ project) VS.Net solution. Yes, I know this is
...Yes I've seen: Best Resources for Learning JavaFX? but it doesn't really answer the
Yes, I know. The existence of a running copy of SQL Server 6.5 in

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.