Function declaration


Hello,

First, I will describe the problem:

1) I have 2 DLLs in 2 folders (file, and npdir)

2) file folder generate file.dll and npdir generate npdir.dll

3) in file folder: filesave.c have the following function

BOOL            DelFilesNDir(HWND hwnd, char * szPath, BOOL bMoveFlag);

4) in npdir folder: npdir.c have the same function

BOOL      DelFilesNDir(HWND hwnd, char * szPath, BOOL bMoveFlag)



They are the same function but placed in 2 different folder. I find it a bit redundant

Can I declare this function in file only? and then use some sort of mechanism in npdir folder to access this function in file?


Thanks



TungVanAsked:
Who is Participating?
 
Infinity08Connect With a Mentor Commented:
>> That's easy, just add the .c file in both projects.
Let me clarify : just add the SAME .c file in both projects.
0
 
Infinity08Commented:
You still want to have that function in both DLL's, but you want only one source file for the function ?

That's easy, just add the .c file in both projects.

An even better way is to make a (static) library for that function (and any other similar shared functions), and include the library in both projects.
0
 
TungVanAuthor Commented:

Thanks, i guess this is the best solution, right?
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
Infinity08Commented:
Maybe someone else has a brighter idea ... just keep this thread open for a while :)
0
 
cryptosidConnect With a Mentor Commented:
you could put the function definition in one file and use 'extern' keyword alongwith the function prototype declaration and include that header file in all your project files.
0
 
nafis_devlprConnect With a Mentor Commented:
you can try this way

put the function in a file say func.c.

then just include the file with path:
#include "path\func.c"

if the path of

func.c is = x:\somedir\func.c
filesave.c is = x:\somedir\file\filesave.c
npdir.c is = x:\somedir\npdir\npdir.c

then in both the filesave.c and npdir.c, include the func.c file in the following way

#include "..\func.c"

Nafis
0
All Courses

From novice to tech pro — start learning today.