Friday, January 19, 2007

A little thing about cl compiler

As we all know, using Visual C++ to compile a little program is not convenient. So I decided to use the cl compiler in the commandline to do this job.

1. Source codes: FolderUtility.h TestFolder.c
//=========================================
//FolderUtility.h part of the source
#include
#include
#include

using namespace std;

void CreateDir(char* path)
{
........
}

........
//==========================================
//TestFolder.c
#include "FolderUtility.h"
#include

int main(void)
{
CreateDir("./sub1/sub2");
EmptyDirectory("./sub1");
printf("Finished.\n");
return 0;
}

At first, I use the command: cl /GX TestFolder.c, but it did not work and pops up some errors.

2. Rename the file "TestFolder.c" to "TestFolder.cpp". Reuse the compiling command again, it works... This proves that the cl compiler will use the postfix of the filename to judge something in the process.

p.s.: /GX means enabling C++ exception handling;

I am not familier with the cl compiler, so there is a lot of things to dig if I want to use it professionally. 

No comments: