NO

Author Topic: Unexplainable compiler error?? "fatal error #1043: Input buffer overflow."  (Read 4072 times)

brettk

  • Guest
I keep getting this compiler error for a specific file. It seems to be complaining about the length of a define, but I have shortened it over and over and it's still complaining. It'll complain about a random line, it's always different. How do I get passed this error so I can compile my code?

Offline TimoVJL

  • Global Moderator
  • Member
  • *****
  • Posts: 2091
Re: Unexplainable compiler error?? "fatal error #1043: Input buffer overflow."
« Reply #1 on: December 09, 2018, 11:49:48 PM »
In Pelles C max line length is below 4096 chars.

EDIT:
Quote
WG14/N1256 Committee Draft โ€” Septermber 7, 2007 ISO/IEC 9899:TC3

โ€”4095 characters in a logical source line
โ€”4095 characters in a character string literal or wide string literal (after concatenation)
« Last Edit: December 12, 2018, 09:45:12 AM by TimoVJL »
May the source be with you

brettk

  • Guest
Re: Unexplainable compiler error?? "fatal error #1043: Input buffer overflow."
« Reply #2 on: December 11, 2018, 11:17:58 PM »
In Pelles C max line length is below 4096 chars.

What is the definition of a "line" then? Because that is definitely not the problem. And I have lines much longer than that.

Offline frankie

  • Global Moderator
  • Member
  • *****
  • Posts: 2096
Re: Unexplainable compiler error?? "fatal error #1043: Input buffer overflow."
« Reply #3 on: December 12, 2018, 09:51:23 AM »
Input file lines length.
Maximum PellesC input line lenght is 4095 chars.
As previously pointed out by Timo, the limits of translation, specify the length of logical lines, see ISO/IEC 9899:2017 ยง5.2.4.1 Translation limits (but also C99-C11), as follow:
Quote
The implementation shall be able to translate and execute at least one program that contains at least
one instance of every one of the following limits:
  • 127 nesting levels of blocks
  • 63 nesting levels of conditional inclusion
  • 12 pointer, array, and function declarators (in any combinations) modifying an arithmetic, structure, union, or void type in a declaration
  • 63 nesting levels of parenthesized declarators within a full declarator
  • 63 nesting levels of parenthesized expressions within a full expression
  • 63 significant initial characters in an internal identifier or a macro name(each universal character name or extended source character is considered a single character)
  • 31 significant initial characters in an external identifier (each universal character name specifying a short identifier of 0000FFFF or less is considered 6 characters, each universal character name specifying a short identifier of 00010000 or more is considered 10 characters, and each extended source character is considered the same number of characters as the corresponding universal character name, if any)
  • 4095 external identifiers in one translation unit
  • 511 identifiers with block scope declared in one block
  • 4095 macro identifiers simultaneously defined in one preprocessing translation unit
  • 127 parameters in one function definition
  • 127 arguments in one function call
  • 127 parameters in one macro definition
  • 127 arguments in one macro invocation
  • 4095 characters in a logical source line
  • 4095 characters in a string literal (after concatenation)
  • 65535 bytes in an object (in a hosted environment only)
  • 15 nesting levels for #included files
  • 1023 case labels for a switch statement (excluding those for any nested switch statements)
  • 1023 members in a single structure or union
  • 1023 enumeration constants in a single enumeration
  • 63 levels of nested structure or union definitions in a single struct-declaration-list
You should check that your source is compliant with each one of the limits above, if your code can compile with a different compiler it should be considered a custom extension of such a compiler, and then the code not portable.
« Last Edit: December 12, 2018, 10:22:52 AM by frankie »
It is better to be hated for what you are than to be loved for what you are not. - Andre Gide

Offline bitcoin

  • Member
  • *
  • Posts: 179
But if I need to use huge string? I tried to put it into resources or into char..  , anyway i see this error.

How i can split the string and merge into memory?

don't want to use visual studio, because it sucks.

Offline TimoVJL

  • Global Moderator
  • Member
  • *****
  • Posts: 2091
A string was not a OP problem.

A huge string can combined from shorter lines.
Code: [Select]
char *huge_str =
"...."
... repeat parts
"....";
May the source be with you

Offline bitcoin

  • Member
  • *
  • Posts: 179
TimoVJL try to put this, in my Pelles it's fail..
https://pastebin.com/8GL5MPuX

Offline DMac

  • Member
  • *
  • Posts: 272
You could break the data up into large chunks and then combine them.  As with this example.

Code: [Select]
#include <stdio.h>
#include <tchar.h>
#include <mapidefs.h>

/// @def NELEMS(a)
///
/// @brief Computes number of elements of an array.
///
/// @param a An array.
#define NELEMS(a) (sizeof(a) / sizeof((a)[0]))

// Create a circular buffer (for Join())
static LPTSTR *ppBuffer = NULL;

/// @brief Concatenates two sub strings into a new string.
///
/// @param str1 A string
/// @param str2 Another string.
///
/// @returns A pointer to a temporarily allocated string.
LPTSTR Join(LPTSTR str1, LPTSTR str2)
{
    register INT tmplen = 0;
    register LPTSTR strtmp;
    static INT StrCnt = 0;

    if(NULL == ppBuffer) // initialize buffer
    {
        ppBuffer = (LPTSTR *) calloc(2, sizeof(LPTSTR));
    }

    tmplen = _tcslen(str1) + _tcslen(str2);

    StrCnt = (StrCnt + 1) & 1;
    if (ppBuffer[StrCnt])
        free(ppBuffer[StrCnt]);

    strtmp = (ppBuffer[StrCnt] = (LPTSTR)calloc(tmplen + 1, sizeof(TCHAR)));

    _tcscat(strtmp, str1);
    _tcscat(strtmp, str2);

    return strtmp;
}

int main(int argc, char *argv[])
{
LPTSTR arrStrings[4];
        arrStrings[0] = "Big string 1 + ";
arrStrings[1] = "Big string 2 + ";
arrStrings[2] = "Big string 3 + ";
arrStrings[3] = "Big string 4";

LPTSTR heapString = "";

for(int i = 0; i < NELEMS(arrStrings); i++)
{
heapString = Join(heapString,arrStrings[i]);
}

printf("%s\n",heapString);
return _getch();
}
No one cares how much you know,
until they know how much you care.

Offline Pelle

  • Administrator
  • Member
  • *****
  • Posts: 2266
    • http://www.smorgasbordet.com
Hard to say much without sample code, but you can also get this error if a macro invocation contains unbalanced parenthesis for example (the compiler thinks the macro goes on, and on, and on, and...)
/Pelle

Offline TimoVJL

  • Global Moderator
  • Member
  • *****
  • Posts: 2091
Test case for error #2076: String literal too long.
May the source be with you

Offline Pelle

  • Administrator
  • Member
  • *****
  • Posts: 2266
    • http://www.smorgasbordet.com
ISO sets a limit of 4095 characters in a string literal after concatenation. Pelles C will accept more, but there must still be a limit.
Anyway, the original complain was about "input buffer overflow" not "string literal too long". Getting off topic, me thinks...
/Pelle