MaxIDE handles C/C++ code

Miscellaneous Forums/General Discussion/MaxIDE handles C/C++ code

Worth a mention ...

The BlitzMax IDE (v1.12) can now handle simple C/C++ code.
Here's something for you to try:

* Save the source code below as:

Sieve.cpp

* Now open 'Sieve.cpp' in the BLitzMax IDE
* Hit F5 to compile.
* Bingo. Executable created.

Note: Ensure the files extension is *.c or *.cpp to prevent the MaxIDE from converting commands to capitalised versions.


(Credits go to FlameDuck for the source code)
#include <iostream>
#include <ctime>
#include <conio.h>

int main(int argc, char* argv[])
{
	int const ITERATIONS = 50000;
	std::cout << "SIEVE OF ERATOSTHENES - " << ITERATIONS << " iterations\n";
	int cps = CLOCKS_PER_SEC / 1000;
	long t = std::clock();
	int Count;

	for(int Iter = 1; Iter <= ITERATIONS; Iter++)
	{
		int flags[8191];
		int i = 0;
		int k = 0;
		int prime = 0;
		Count = 0;
		
		for (i = 0; i <= 8190; i++)
		{
			flags[i] = 1;
		}

		for (i = 0; i <= 8190; i++)
		{
			if (flags[i] == 1)
			{
				prime = i + i;
				prime = prime +3;
				k = i + prime;
				while (k <= 8190)
				{
					flags[k] = 0;
					k = k + prime;
				}
				Count = Count + 1;
			}
		}
	}
	t = std::clock() - t;
	t = t / cps; // because there might be more than 1000 CLOCKS_PER_SECOND
	std::cout << ITERATIONS << " iterations took " << t << " millisecs.\n";
	std::cout << "Primes found: " << Count << "\n";
	std::cout << "Any key to end ...";
	getch();
}
Now you can dabble in a bit of C without having to install other doings.

I'm guessing you have to have MinGW installed for this to work. I just tried it and I get a compile error.

Guess its not possible to mix blitzmax and c/c++

Guess its not possible to mix blitzmax and c/c++
I think you have to keep them in seperate files.. but it's still "possible" to an extent...

Just to note. I've tried this code.
BlitzMax IDE did still convert it into capitalized versions, even though I saved it as a .cpp

Thus it didn't compile

At least the Mac version did. I don't think the Windows version will do it elseway.

Now I believe you could turn that autocapilatizer off in your preferences or IDE settings or whatever. I think that there lies the key.

Provided you save it as a .cpp file, I think blitzmax will not capitalise it.

Yup, when I saved it as a .cpp (lowercase extension) it didnt autocapatalize it.

it will parse the code as if it were BMax code if you cut and paste it though.. I had that problem when I first tried the C++ stuff from the docs...
I guess you ca always cut and paste it in notepad or something first though...

Has this not always been the case?