Solved

Function declaration

Posted on 2006-07-14
6
273 Views
Last Modified: 2010-04-15

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



0
Comment
Question by:TungVan
6 Comments
 
LVL 53

Expert Comment

by:Infinity08
Comment Utility
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
 
LVL 53

Accepted Solution

by:
Infinity08 earned 75 total points
Comment Utility
>> That's easy, just add the .c file in both projects.
Let me clarify : just add the SAME .c file in both projects.
0
 

Author Comment

by:TungVan
Comment Utility

Thanks, i guess this is the best solution, right?
0
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
LVL 53

Expert Comment

by:Infinity08
Comment Utility
Maybe someone else has a brighter idea ... just keep this thread open for a while :)
0
 
LVL 5

Assisted Solution

by:cryptosid
cryptosid earned 25 total points
Comment Utility
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
 
LVL 7

Assisted Solution

by:nafis_devlpr
nafis_devlpr earned 25 total points
Comment Utility
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

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

An Outlet in Cocoa is a persistent reference to a GUI control; it connects a property (a variable) to a control.  For example, it is common to create an Outlet for the text field GUI control and change the text that appears in this field via that Ou…
Preface I don't like visual development tools that are supposed to write a program for me. Even if it is Xcode and I can use Interface Builder. Yes, it is a perfect tool and has helped me a lot, mainly, in the beginning, when my programs were small…
The goal of this video is to provide viewers with basic examples to understand and use structures in the C programming language.
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use while-loops in the C programming language.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now