Solved

Function declaration

Posted on 2006-07-14
6
283 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 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
Independent Software Vendors: 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 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

Independent Software Vendors: 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!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
voltage to force translation ? 8 100
Test against App 49 138
Parsing XML instructions in Java/any other language.... 3 121
Secondary drive is failing... D Volume 11 51
This is a short and sweet, but (hopefully) to the point article. There seems to be some fundamental misunderstanding about the function prototype for the "main" function in C and C++, more specifically what type this function should return. I see so…
Examines three attack vectors, specifically, the different types of malware used in malicious attacks, web application attacks, and finally, network based attacks.  Concludes by examining the means of securing and protecting critical systems and inf…
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.
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.

756 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