Intel® C++ Compiler
Support and discussions for creating C++ code that runs on platforms based on Intel® processors.

Intel C++ Compiler.

JohnNichols
Valued Contributor II
435 Views

Dear Noorjahan:

Thank you for your previous response.  I appreciate that this forum is for the support of Intel C++ compilers.  I do not normally use C++ or C.  I am just having some fun at the end of a long semester. 

I normally code in Fortran (Intel) I started with the grandmother of Intel Fortran - MS Fortran 3.13 in about 1987. 

Intercal is a rather interesting old C program that has a lot of interesting quirks,  I have now reached the stage of using the Intel C++ Compiler to get the program running in a modern compiler.  Your clue a few days ago allowed me to solve the challenging problem with the unions, thank you.  Why would I do this - insanity. 

I have a little bit to go. 

I have found that there are really two good forums in the world, this one and the equivalent FORTRAN one.  Interestingly the Fortran forum is more active and a little bit outside the Fortran box, although the days of a set of disks in a box, with a printed manual, in a box are long gone.  Pity.  I still have the 1988 Fortran manual beside my desk. 

You can regard most things I post as community, sorry, but COVID keeps me at home alone coding and the Fortran forum keeps me sane, and it is a lot cheaper than 100 per hour for a shrink, and Mary is perfect with her answers.  

Warm regards and splice the main brace. 

JMN

Real question :: How do I get MSVS to use the Intel C++ compiler?  I can not see a switch. 

 

0 Kudos
9 Replies
JohnNichols
Valued Contributor II
420 Views

Is #pragma once supported in Intel c++, it does not throw an error, but I cannot find it in your manuals?

jimdempseyatthecove
Black Belt
416 Views

>>How do I get MSVS to use the Intel C++ compiler?

Right click on the project in the solution explorer and then the pop-up shows Use Intel C++ (changes to Use MS C++ when ICPP selected).

Jim Dempsey

JohnNichols
Valued Contributor II
407 Views

Intercal defines a function ::

void lose(char* m, INT32 n, char* s)
{
	fprintf(stderr, "\nIntercal or hell - 15A -- inside lose!!\n");
	(void)fprintf(stderr,
		"ICL%c\n%c\n%c\nI\t",
		m[0], m[1], m[2]);
	if (s)
	{
		(void)fprintf(stderr, "\nIntercal or hell - 15B!!\n");
		(void)fprintf(stderr, m + 4, s, n);
	}
	else
	{
		(void)fprintf(stderr, "\nIntercal or hell - 15C!!\n");
		(void)fprintf(stderr, m + 4, n);
	}

	(void)fprintf(stderr, "        CORRECT SOURCE AND RESUBNIT - Here and now!\n");
	(void)fprintf(stderr, "\nIntercal or hell - 15D exit lose!!\n");
	exit(atoi(m));
}

 

It is part of the humour of this program, it means you lose and the program stops.  

if I use the Intel icl compiler directly the code runs and does not throw an error.  

Inside MSVS using Intel C compiler I get the error if these are the defines passed to the lose routine. 

 

Screenshot 2021-05-07 191635.png

 


void checklabel(INT32 label)
{
	if (label < 1 || label > 65535)
		lose(E197, yylineno, (char*)NULL);
}


Lose does not like the defines, but I cannot work out why - I just do not know enough at C characters. 

 

 

JohnNichols
Valued Contributor II
403 Views

Before I go through and change a couple of hundred lines,  

if I change the #defines to string

change lose(char *  m, to loser(string m,

write loser using cout << m<< endl;

that should work.  

Ok in the morning.  

jimdempseyatthecove
Black Belt
371 Views

>>"const char*" is incompatible with parameter type of "char*".

C++ has stronger type checking than C.

A "string literal" has a type of "const char*" whereas the subroutine lose stated it requires "char*" and this interface parameter type permits the function to modify what is located at the char*.

I suggest you change the parameter types of lose from char* to const char*

*** however, the C runtime function fprintf (is likely) using "char*" so that can trip you up.

The alternate way is to keep lose as-is, then add three shell functions with permutations of const char*

Then work out which is to have the body of the function and which are to be shell functions with appropriate casts.

Isn't strongly typed language programming fun!

Jim Dempsey

 

JohnNichols
Valued Contributor II
366 Views

No I tried adding the const to the char and it still spat the pacifier.  

 

But why does the program pass without problem through ICL  with prog.cpp and the exact same program in MSVS throws the errors,  there must be a switch in MSVS to change something?  I am using the ICL compiler in MSVS. 

No it think it is easier to use the strong language and make all the defines strings and use cout. 

Flex and Bison now create cpp programs so this is what created the need to go cpp and then these errors popped up in MSVS. 

C# is strongly typed and you would not get away with half the things done in Intercal in c#. 

But FLEX and  BISON add defines that refer to the line locations in the original input programs and so it is a challenge to find the mistakes.  I had to strip that stuff out to find some of the problems, or you have to have multiple files open. 

The fun is looking at a couple of programmers, who are good, but are writing a Monty Python program.  

I reminds me of the old days when it was more fun and the world was not constricted by a large python of indeterminate use. 

 

NoorjahanSk_Intel
Moderator
325 Views

Hi,

Thanks for reaching out to us.

 

>>Is #pragma once supported in Intel c++, it does not throw an error, but I cannot find it in your manuals?

Compiler do support #pragma once . Refer to the below link:

https://software.intel.com/content/www/us/en/develop/documentation/cpp-compiler-developer-guide-and-...

 

 

>>No I tried adding the const to the char and it still spat the pacifier

 

We tried your snippet using const char*, it got compiled using both compilers. As the string literal accepts parameter to be constant char*, we need to change char* to const char* in the code. Please find below code sample:

 

 

 

#include<iostream>
#include<string>
using namespace std;
#define E197 "197 so"
typedef int INT32;
INT32 label, yylineno;

void lose(const char* m, INT32 n, char* s)
{

	fprintf(stderr, "\nIntercal or hell - 15A -- inside lose!!\n");
	(void)fprintf(stderr,
		"ICL%c\n%c\n%c\nI\t",
		m[0], m[1], m[2]);
	if (s)
	{
		(void)fprintf(stderr, "\nIntercal or hell - 15B!!\n");
		(void)fprintf(stderr, m + 4, s, n);
	}
	else
	{
		(void)fprintf(stderr, "\nIntercal or hell - 15C!!\n");
		(void)fprintf(stderr, m + 4, n);
	}

	(void)fprintf(stderr, "        CORRECT SOURCE AND RESUBNIT - Here and now!\n");
	(void)fprintf(stderr, "\nIntercal or hell - 15D exit lose!!\n");
	exit(atoi(m));
}

void checklabel(INT32 label)
{
	if (label < 1 || label > 65535)
	  lose(E197, yylineno, (char*)NULL);
}
int main()
{
	checklabel(label);
	return 0;
}

 

 

 

Thanks & Regards

Noorjahan

 

NoorjahanSk_Intel
Moderator
260 Views

Hi,


Reminder:

Could you please confirm whether your issue is resolved. If yes, let us know if we can close this thread from our end.


Thanks & Regards

Noorjahan


NoorjahanSk_Intel
Moderator
200 Views

Hi,

We are closing this thread assuming your issue has been resolved.

We will no longer respond to this thread. If you require additional assistance from Intel, please start a new thread.

Any further interaction in this thread will be considered community only.


Thanks & Regards

Noorjahan


Reply