This wasn’t an issue for us, but a potential problem when moving numerical code between Unix-like systems is that the function gamma computes different things on different systems. After porting the library to Linux, we built it on OS X without any issue. Our build process became two orders of magnitude simpler when we switched over to a crude, old-fashioned make file. We started out using autoconf, but that was overkill for our project. That would suppress unused variable warnings in Visual C++, but not in gcc. When we changed the function signature to void foo(int a, int /* b */), that made both compilers happy. We had usually handled that by making b the first line of the implementation. There were several places in our code where a variable was deliberately unused but retained in a function signature. Suppose a function has signature void foo(int a, int b) but b is unused. Print "chmod returned " + retcode + " on " + path If file.endswith(".h") or file.endswith(".cpp"): # Script must be in the same location as these directories.ĭirectories = # List of directories of files to add newlines to. We copy our source tree to a Linux box then run the following Python code on that box to insert the extra newline characters when needed. As I understand it, Visual Studio inserts a linebreak after including header files, but gcc may not and so gcc needs to issue a warning in this case while Visual Studio does not. Apparently there’s no gcc switch to turn this off, and it may not be prudent to turn it off if you could. We got hundreds of warnings of the form warning: no newline at end of file when we first attempted to compile our code on Linux. Visual C++ does not require source and header files to end with newline characters, but gcc does. Also, by not referring specifically to 32-bit Windows, we’re OK moving the code to 64-bit Windows. That way we could do a preliminary test of the portable subset of the code while still working on Windows where we’re more comfortable. Clift Norris came up with the clever idea of using #ifndef EXCLUDE_WINDOWS_ONLY_CODE instead. Our first thought was to put #ifdef WIN32 directives around that code. Some of our code only runs on Windows, and only needs to run on Windows. Here are a few lessons learned from porting a numerical library recently from Windows/Visual C++ to Linux/ gcc.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |