inline is out of scope?

below is my program

general.h
1
2
3
4
5
6
#ifndef GENERAL_H
#define GENERAL_H

inline void func_exitprint(char *s);

#endif 


general.cpp
1
2
3
4
5
6
7
8
9
10
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include "general.h"

inline void func_exitprint(char *s)
{
	printf("%s\n",s); exit(1);
}


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include "general.h"

int main()
{
	
	int val=100;
	
	func_exitprint("abc");
	
	return 0;
}

visualC++ 2008 keeps telling me
 
error LNK2019: unresolved external symbol "void __cdecl func_exitprint(char *)" (?func_exitprint@@YAXPAD@Z) referenced in function _main


what is the wrong with it?
if I define all of the inline function in general.h
everything would be ok
thank you very much
Last edited on
If I recall correctly, inline function definitions have to be visible when they're called. That means, they cannot be defined in a separate cpp file.
If you want the function to be inlined you have to make the definition visible everywhere it's used
Thanks a lot
So I guess I have to put my definition in the same file with no choice
Just to clarify, the definition belongs into the header.
Topic archived. No new replies allowed.