Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Function declaration

Posted on 2006-07-14
6
Medium Priority
?
295 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 300 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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 100 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 100 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

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…
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…
The goal of this video is to provide viewers with basic examples to understand recursion in the C programming language.
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use for-loops in the C programming language.
Suggested Courses

609 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