# Problem in using typedef with c++

**URL:** <https://www.ruby-forum.com/t/problem-in-using-typedef-with-c/132348>\
**Category:** Rails\
**Created:** [March 19, 2008, 10:57am UTC](https://www.ruby-forum.com/t/problem-in-using-typedef-with-c/132348 "2008-03-19T10:57:01Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![tonyaim83](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/ecb155/32.png) [@tonyaim83](https://www.ruby-forum.com/u/tonyaim83)\
**Post date:** [March 19, 2008, 10:57am UTC](https://www.ruby-forum.com/t/problem-in-using-typedef-with-c/132348/1 "2008-03-19T10:57:01Z")

</div>

Hi  
My code is as follows :-  
example.h

#include"iostream.h"  
using namespace std;  
typedef int MYINT;  
void sum(MYINT a, MYINT b);

example.cpp  
#include"example.h"  
void sum(MYINT a, MYINT b)  
{  
MYINT c;  
c=a +b;  
cout\<\<c;  
}

example.i  
%module example  
%{  
#include"example.h"  
extern void sum(MYINT a, MYINT b);  
%}

#include “example.h”  
extern void sum(MYINT a,MYINT b);

example.rb

require “example.so”  
MYINT a=10;  
MYINT b=20;  
Example.sum(a,b);

But it is giving me error undefined MYINT when i’m trying to compile  
this  
Kindly help

---

<div class="post-metadata">

**Author:** ![tonyaim83](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/ecb155/32.png) [@tonyaim83](https://www.ruby-forum.com/u/tonyaim83)\
**Post date:** [March 19, 2008, 11:05am UTC](https://www.ruby-forum.com/t/problem-in-using-typedef-with-c/132348/2 "2008-03-19T11:05:15Z")

</div>

Abhi Us wrote:

> Hi  
> My code is as follows :-  
> example.h  
> …  
> example.rb
> 
> require “example.so”  
> MYINT a=10;  
> MYINT b=20;  
> Example.sum(a,b);
> 
> But it is giving me error undefined MYINT when i’m trying to compile  
> this  
> Kindly help

you should probably post this in the scrictly ‘ruby’ (rather than ‘ruby  
on rails’) forum -

[http://www.ruby-forum.com/forum/4](http://www.ruby-forum.com/forum/4)
