Thread: error: no matching function for call to

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

    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:
       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);
          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 #
             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 *> ( );
                   theDevirCallsiteMap.insert(std::make_pair(strdup(buffer), v));
                else {
                   // add the callsite info to the end of the exisiting vector
    Thank you.

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    The edge of the known universe
    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:
    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.

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, 03: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