Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to hide helper functions from public API in c
    primarykey
    data
    text
    <p>I'm working on a project and I need to create an API. I am using sockets to communicate between the server (my application) and the clients (the other applications using my API). </p> <p>This project is in c not C++</p> <p>I come from a linux background and this is my first project using Windows, Visual Studio 2008, and dll libraries. </p> <p>I have communication working between the client and server, but I have some that is duplicated on both projects. I would like to create a library (probably a dll file), that both projects can link to so I don't have to maintain extra code. </p> <p>I also have to create the library that has the API that I need to make available for my clients. Within the API functions that I want public are the calls to these helper functions that are "duplicated code", I don't want to expose these functions to my client, but I do want my server to be able to use those functions. How can I do this?</p> <p>I will try to clarify with an example. This is what I started with.</p> <p>Server Project:</p> <pre><code>int Server_GetPacket(SOCKET sd); int ReceiveAll(SOCKET sd, char *buf, int len); int VerifyLen(char *buf); </code></pre> <p>Client Project:</p> <pre><code>int Client_SendCommand(int command); int Client_GetData(int command, char *buf, int len); int ReceiveAll(SOCKET sd, char *buf, int len); int VerifyLen(char *buf); </code></pre> <p>This is kind of what I would like to end up with:</p> <pre><code>//Server Project: int Server_GetPacket(SOCKET sd); // library with public and private types // private API (not exposed to my client) int ReceiveAll(SOCKET sd, char *buf, int len); int VerifyLen(char *buf); // public API (header file available for client) int Client_SendCommand(int command); int Client_GetData(int command, char *buf, int len); </code></pre> <p>Thanks any help would be appreciated.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload