error: no matching function for call to

This is a discussion on error: no matching function for call to within the C++ Programming forums, part of the General Programming Boards category; Hi, I am trying to solve a problem with regards with getline() /usr/home/muhammad/Open64/osprey/../osprey/ipa/main/analyze/ipa_devirtual.cxx: In member function 'void IPA_VIRTUAL_FUNCTION_TRANSFORM::Read_Callsite()': /usr/home/muhammad/Open64/osprey/../osprey/ipa/main/analyze/ipa_devirtual.cxx:830: error: ...

  1. #1
    Registered User
    Join Date
    Jan 2013
    Location
    Kota Bharu, Malaysia
    Posts
    1

    error: no matching function for call to

    Hi, I am trying to solve a problem with regards with getline()

    /usr/home/muhammad/Open64/osprey/../osprey/ipa/main/analyze/ipa_devirtual.cxx: In member function 'void IPA_VIRTUAL_FUNCTION_TRANSFORM::Read_Callsite()':
    /usr/home/muhammad/Open64/osprey/../osprey/ipa/main/analyze/ipa_devirtual.cxx:830: error: no matching function for call to 'getline(char**, long unsigned int*, FILE*&)'
    gmake[3]: *** [ipa_devirtual.o] Error 1
    gmake[3]: Leaving directory `/usr/home/muhammad/Open64/osprey/targdir/ipa'
    gmake[2]: *** [default] Error 2

    Code snippet here:
    Code:
    void IPA_VIRTUAL_FUNCTION_TRANSFORM::Read_Callsite()
    {
       if (IPA_Devirtualization_Input_File) {
          FILE *fp = fopen(IPA_Devirtualization_Input_File, "r");
          if (fp == NULL) {
             fprintf(stderr, "Invalid DEVIR_CALLSITE file %s!\n", IPA_Devirtualization_Input_File);
             return;
          }
          size_t sz = 4096;
          char *linebuf = (char*)malloc(sz);
          char buffer[2048];
          int lineno;
          int callsite_id;
          while (getline(&linebuf, &sz, fp) != -1) {
             if (*linebuf == '#') {
                // comment line starts with #
                continue;
             }
             if ( sscanf(linebuf, "Caller:%s line:%d callsite_id:%d",
                         buffer, &lineno, &callsite_id) == 3) {
                DevirCallsiteInfo *p = new DevirCallsiteInfo(buffer, lineno, callsite_id);
                DevirCallsiteMap::iterator itr = theDevirCallsiteMap.find(buffer);
                if (itr == theDevirCallsiteMap.end()) {
                   // create a new entry with a new vector
                      vector<DevirCallsiteInfo *> *v = new vector<DevirCallsiteInfo *> ( );
                   v->push_back(p);
                   theDevirCallsiteMap.insert(std::make_pair(strdup(buffer), v));
                }
                else {
                   // add the callsite info to the end of the exisiting vector
                   itr->second->push_back(p);
                }
             }
    Thank you.

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,592
    Well lookup getline() in the manual and find out what parameters it does take.
    getline(3): delimited string input - Linux man page

    Did you #include <cstdio> ?

    Did you set the right conditional compilation flags in your makefile
    Quote Originally Posted by manual page
    Feature Test Macro Requirements for glibc (see feature_test_macros(7)):

    getline(), getdelim():
    Since glibc 2.10:
    _POSIX_C_SOURCE >= 200809L || _XOPEN_SOURCE >= 700
    Before glibc 2.10:
    _GNU_SOURCE
    If you don't set these flags correctly, then the declaration of getline() will be invisible, even if you include the correct header file.


    For a C++ program, you're using a lot of 'C' API's.
    How about fstream and sstream?
    <fstream> - C++ Reference
    stringstream - C++ Reference
    And using new instead of malloc to allocate memory.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. No matching function for call to...
    By 20120903 in forum C Programming
    Replies: 13
    Last Post: 09-07-2012, 01:44 PM
  2. Constructors: No Matching function for call error
    By Emilio Martin in forum C++ Programming
    Replies: 5
    Last Post: 03-22-2012, 12:49 PM
  3. Replies: 8
    Last Post: 07-08-2011, 01:16 PM
  4. No Matching Function Call for Constructor
    By manasij7479 in forum C++ Programming
    Replies: 5
    Last Post: 02-07-2011, 02:29 PM
  5. no matching function for call to
    By f6ff in forum C++ Programming
    Replies: 4
    Last Post: 06-10-2006, 03:34 PM

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