Skip to content

Conversation

@evandrocoan
Copy link
Contributor

fix #68 - Cannot print function pointer

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

struct test_debugger { void var() {} };
void fun_void_void(){};
void fun_void_double(double d){};
double fun_double_double(double d){return d;}

int main(void) {
    int* var;

    std::cout << std::boolalpha;
    std::cout << tfm::format( "0. %s", &var ) << std::endl;
    std::cout << tfm::format( "1. %s", &fun_void_void ) << std::endl;
    std::cout << tfm::format( "2. %s", &fun_void_double ) << std::endl;
    std::cout << tfm::format( "3. %s", &fun_double_double ) << std::endl;
    std::cout << tfm::format( "4. %s", &test_debugger::var ) << std::endl;
    return 0;
}

Prints:

$ g++ -o main.exe -g -ggdb test.cpp --std=c++98 && ./main.exe
0. 0xffffcbb0
1. 0x100401100
2. 0x100401107
3. 0x100401113
4. 0x100405f10

$ g++ -o main.exe -g -ggdb test.cpp --std=c++11 && ./main.exe
0. 0xffffcbb0
1. 0x100401100
2. 0x100401107
3. 0x100401113
4. 0x100405b70

@evandrocoan evandrocoan force-pushed the full_pointer_support branch 6 times, most recently from 882e49c to 947b765 Compare February 2, 2020 19:20
#include<iostream>
#include "tinyformat.h"

struct test_debugger { void var() {} };
void fun_void_void(){};
void fun_void_double(double d){};
double fun_double_double(double d){return d;}

int main(void) {
    int* var;

    std::cout << std::boolalpha;
    std::cout << tfm::format( "0. %s", &var ) << std::endl;
    std::cout << tfm::format( "1. %s", &fun_void_void ) << std::endl;
    std::cout << tfm::format( "2. %s", &fun_void_double ) << std::endl;
    std::cout << tfm::format( "3. %s", &fun_double_double ) << std::endl;
    std::cout << tfm::format( "4. %s", &test_debugger::var ) << std::endl;
    return 0;
}
@evandrocoan
Copy link
Contributor Author

Passing all tests now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cannot print function pointer

1 participant