0

I am writting a DLL:

#include "stdafx.h" _DLLAPI int __stdcall myDLLFunc() { return test(4); } int test(int arg) { return arg * arg; } 

But when I try to compile it in MS VC++ Express it says:

error C3861: 'test': identifier not found

How do I call test from myDLLFunc? Am I missing the obvious?

Thanks in advance.

1 Answer 1

4

Put the called function ahead of the caller in your code and it should compile. C++ does not do 'look ahead' for called functions, they must be declared ahead of any usage.

#include "stdafx.h" int test(int arg) { return arg * arg; }_DLLAPI int __stdcall myDLLFunc() { return test(4); } 

Typically, you would keep the function's declaration separate (in a header file) from the definition (in the code file) to reduce dependency complexity.

Sign up to request clarification or add additional context in comments.

2 Comments

Or you can do forward declaration of test() without moving test() above myDLLFunc().
@Ganesh - thanks, I added a note about header/code separation

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.