Это компилируется со старыми версиями g cc, но не работает с G CC 7 с C ++ 17. Это ошибка, которую я получаю:
ошибка: недопустимое преобразование из 'char' в 'const char *' [-fpermissive] end_of_line = '\ 0';
Кажется, не удается устранить эту ошибку компиляции.
Это код:
/*!
* \brief Find the beginning of the next line in the given buffer.
*
* \param[in] str buffer to search for the beginning of the next line
* \param[inout] ctx
* \parblock
* pointer to the end of the line (saved by this method)
*
* This pointer must be valid, and it must be set to NULL by the caller the first time.
* \endparblock
*
* \return a pointer to the first character in the next line, or NULL if we have already hit EOF
*/
const char* Foo::GetNextLine(const char* str, const char** ctx)
{
if(str == NULL)
{
return NULL;
}
// Save a pointer to the end of the line (first time, it should be set to NULL by the caller).
const char*& end_of_line = *ctx;
if(end_of_line && *end_of_line == '\0')
{
end_of_line = '\0';
return NULL;
}
// The start of this line is one character after the end of the last one.
const char* start_of_line = end_of_line ? end_of_line + 1 : str;
// Are we at the end of the whole thing?
if(*start_of_line == '\0')
{
end_of_line = '\0'; // Reset the context state to get ready for the next load!
return NULL;
}
// Read forward to the end of the line.
end_of_line = start_of_line;
while(*end_of_line != '\n')
{
if(*end_of_line == '\0')
{
break;
}
++end_of_line;
}
return start_of_line;
}