Solved

Function declaration

Posted on 2006-07-14
6
280 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
ID: 17108134
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
ID: 17108147
>> 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
ID: 17108169

Thanks, i guess this is the best solution, right?
0
Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

 
LVL 53

Expert Comment

by:Infinity08
ID: 17108228
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
ID: 17112046
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
ID: 17113832
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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This tutorial is posted by Aaron Wojnowski, administrator at SDKExpert.net.  To view more iPhone tutorials, visit www.sdkexpert.net. This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho…
Summary: This tutorial covers some basics of pointer, pointer arithmetic and function pointer. What is a pointer: A pointer is a variable which holds an address. This address might be address of another variable/address of devices/address of fu…
The goal of this video is to provide viewers with basic examples to understand opening and writing to files in the C programming language.
The goal of this video is to provide viewers with basic examples to understand recursion in the C programming language.

773 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