views:

56

answers:

3

I have read on Wikipedia that the Cyclone programming language is a safe dialect of the C programming language so consider the following C code.

int strlen(const char *s)
{
    int iter = 0;
    if (s == NULL) return 0;
    while (s[iter] != '\0') {
        iter++;
    }
    return iter;
}

This function assumes that the string being passed in is terminated by NUL ('\0'). But if we pass a string like this,

char buf[] = {'h','e','l','l','o','!'}

it would cause strlen to iterate through memory not necessarily associated with the string s. So there is another version of this code in Cyclone

int strlen(const char ? s)
{
    int iter, n = s.size;
    if (s == NULL) return 0;
    for (iter = 0; iter < n; iter++, s++) {
       if (*s == '\0') return iter;
    }
    return n;
}

Can I use Cyclone in Visual Studio or do I have to donwload a new compiler?

+2  A: 

You will need Cyclone. It is also the name of the compiler. The Cyclone compiler is available in source code here. The Cyclone compiler can, according to the documentation, only be compiled with GCC. Check this to compile the Cyclone compiler.

You can use it from Visual Studio if you provide custom rules for the *.cyc files. This way you can use the IDE as a better text editor. For syntax highlighting and style assign *.cyc to the C language extention list.

jdehaan
+2  A: 

You can run custom tools for a file with a specific filename extension. The MSDN Library article on how to setup the custom build rule is here. Beware that this is pretty broken in VS2010 right now.

Hans Passant
A: 

I know it does not answer your question, but it seems that Cyclone project is pretty much dead. The last announcements seem to be from 2006: http://lists.cs.cornell.edu/pipermail/cyclone-announce-l/

Nemanja Trifunovic
That's probably mostly true, but that's not a good reason to not play with it :)
Gian