Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is this program erroneously rejected by three C++ compilers?

People also ask

Why does C have different compilers?

There are many things within C that are implementation-defined. This means that the people who create the compilers can choose how they want to handle those situations. In general, for portability it is best in most cases to not rely on undefined behavior, even when most or all compilers handle it the same way.

Why are there so many compilers for C?

As for compilers, both languages have long histories, and have existed long enough that there were many “payware” compilers for them, and C - in particular - is simple enough to compile that there were numerous compilers for it “back in the day”.

How many C compilers are there?

Software Engineering C There are over 50 compilers for C like ICC by Intel to GNU GCC by GNU Project. The focus of having multiple compilers is to optimize the compiled C code for specific hardware and software environments.

Why are there no C compilers for Windows?

Microsoft has a monopoly. I meant that small companies developing new C compilers won't sell a lot of them.


Originally from Overv @ reddit.


Try this way:

enter image description here


Your < and >, ( and ), { and } don't seem to match very well; Try drawing them better.


In the standard, §2.1/1 specifies:

Physical source file characters are mapped, in an implementation-defined manner, to the basic source character set (introducing new-line characters for end-of-line indicators) if necessary.

Your compiler doesn't support that format (aka cannot map it to the basic source character set), so it cannot move into further processing stages, hence the error. It is entirely possible that your compiler support a mapping from image to basic source character set, but is not required to.

Since this mapping is implementation-defined, you'll need to look at your implementations documentation to see the file formats it supports. Typically, every major compiler vendor supports (canonically defined) text files: any file produced by a text editor, typically a series of characters.


Note that the C++ standard is based off the C standard (§1.1/2), and the C(99) standard says, in §1.2:

This International Standard does not specify
— the mechanism by which C programs are transformed for use by a data-processing system;
— the mechanism by which C programs are invoked for use by a data-processing system;
— the mechanism by which input data are transformed for use by a C program;

So, again, the treatment of source files is something you need to find in your compilers documentation.


You could try the following python script. Note that you need to install PIL and pytesser.

from pytesser import *
image = Image.open('helloworld.png')  # Open image object using PIL
print image_to_string(image)     # Run tesseract.exe on image

To use it, do:

python script.py > helloworld.cpp; g++ helloworld.cpp

You forgot to use Comic Sans as a font, that's why its erroring.