Link to home
Start Free TrialLog in
Avatar of JonMac
JonMac

asked on

About map..

Hi Friends
       i have a problem... i have a file(say file1.cxx) in which i declare a map & through a function on this file say enter i can insert value in this map..now i want to call this function from another file having extension .c & wants to enter value in it from that file..but linker error comes .. how it can be possible..

bye
Jonmac
ASKER CERTIFIED SOLUTION
Avatar of MDarling
MDarling

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of MDarling
MDarling

=== main.c ===

#include "myheader.h"

int main()
{
    map_insert("hello");
    map_insert("world");
    return 0;
}

=== header file ===

#ifndef myheader_h
#define myheader_h

#ifdef __cplusplus
extern "C" {
#endif

int map_insert(char* s);

#ifdef __cplusplus
};
#endif

#endif


=== C++ Source ===

#include "myheader.h"
#include <iostream>

using namespace std;

int map_insert(char* s)
{
    cerr << s << ' ';
    return 0;
}
Avatar of Axter
Which are you trying to do?

[1] Are you trying to access a function in a *.cxx file from a *.c file?

OR

[2] Are you trying to access a function in a *.c file from a *.cxx file?
JonMac,
Did you forget this question?
Dear

I think you forgot this question. I will ask Community Support to close it unless you finalize it within 7 days. You can always request to keep this question open. But remember, experts can only help you if you provide feedback to their questions.
Unless there is objection or further activity,  I will suggest to accept

     "MDarling"

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
======
Werner
Force accepted

** Mindphaser - Community Support Moderator **