typedef long int comparison

This is a discussion on typedef long int comparison within the C++ Programming forums, part of the General Programming Boards category; Hello, I have a library which typedefs a long int Code: //from tpd1.h typedef long int Int and there is ...

  1. #1
    Registered User nepper271's Avatar
    Join Date
    Jan 2008
    Location
    Brazil
    Posts
    50

    typedef long int comparison

    Hello,

    I have a library which typedefs a long int

    Code:
    //from tpd1.h
    
    typedef long int Int
    and there is another library which also typedefs a long int

    Code:
    //from tpd2.h
    
    typdef long int integer
    There is a function from the second library which should receive a integer*, but i have to give it a Int*. It won't accept (invalid conversion).

    To add it in my .cpp, I use

    Code:
    #include "tpd1.h"
    extern "C" {
    #include "tpd2.h"
    }
    because tpd2.h have some things from Fortran.
    These won't work:

    Code:
    Int i;
    integer j;
    
    Int *pi = &j; //wont work
    integer *pj = &i; //wont work
    but the following will

    Code:
    Int *pi = (Int *) (&j); //will work
    integer *pj = (integer *) (&i); //will work

    Anyone can't tell me why they implicitly convert, and how to make them do it.

    Thank you,
    Nepper271

  2. #2
    Registered User nepper271's Avatar
    Join Date
    Jan 2008
    Location
    Brazil
    Posts
    50
    Never mind this post. It is working now.

    Sorry for the inconvenience

  3. #3
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    I'm wondering whether the extern C is doing something interesting? If I use the following file:
    Code:
    typedef long int Int;
    
    typedef long int Integer;
    
    int main(void) {
        Int a = 5;
        long int *b;
        b = &a;
        Integer *c;
        c = &a;
    }
    I can't get g++ to complain.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 1
    Last Post: 04-23-2011, 08:40 PM
  2. Replies: 1
    Last Post: 10-11-2010, 01:53 AM
  3. C++ - unsigned long long int comparison
    By grimuth in forum C++ Programming
    Replies: 8
    Last Post: 05-05-2010, 10:20 AM
  4. std::string comparison versus int comparison
    By leeor_net in forum C++ Programming
    Replies: 3
    Last Post: 04-12-2009, 07:28 AM
  5. STLport with MingW - Long Long error on project build
    By Mario F. in forum C++ Programming
    Replies: 2
    Last Post: 08-21-2006, 08:55 AM

Tags for this Thread


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21