Frequently asked questions about vbcc (under work) GENERAL QUESTIONS Q: vbcc has such a low version number whereas compiler x has a much higher one. Does that mean that vbcc is very unstable? A: No. Version numbers are no measure for reliability. Q: Is vbcc ANSI/ISO-compliant? A: For any practical purposes, yes. Q: vbcc complains about my source files. A: While there might be an error in vbcc (see BUGREPORTS), usually the source is no correct C. Check if it really is conforming C. Q: But it must be correct, because compiler xyz accepts it. A: That doesn't mean a lot. Many compilers provide specific extensions or accept sources that are no conforming C. Q: But I copied it straight from a textbook about C. A: That doesn't mean a lot. Many books about C are very bad. Q: But my instructor said it was correct. A: That doesn't mean a lot. Many instructors have never even seen the standard for C. Q: What are good books, then? A: Kernighan, Ritchie: The C Programming Language, 2nd edition is pretty good. Q: vbcc doesn't like //-comments? A: Yes, because there are no such comments in the current C standard. However, the -+ option of vc makes vbcc accept them. But note that this forces vbcc to break the ANSI standard. (And on AmigaOS be careful with -+ at the end of the command line.) Q: vbcc doesn't like long long? A: Yes, because there is no long long in the current C standard. vbcc may implement long long in the future. Q: Is C++-support planned? A: Currently not. Q: Is C9X-support planned? A: Yes, but it depends on my free time. Q: Is support for any other languages planned? A: Someone is thinking about/working on an Oberon frontend. But don't hold your breath. Q: How about supporting target x? A: I want to support as many targets as possible, but my time is limited and usually I need to have such hardware to write a backend for it. Also, if possible, there should already be an assembler and linker. Of course, the best way to get support for a certain target, is to write a backend yourself. How to do it is documented somewhat in interface.doc (not terribly well unfortunately) and I'll help you if you contact me. Q: Can I specify registers to pass arguments to functions? A: Yes, with the __reg keyword. Have a look at vbcc.doc. Q: Can I use inline-assembly with vbcc? A: Yes. Have a look at vbcc.doc. Q: Can you add a warning for x? A: Perhaps. Just let me know what warnings you'd like. But first, try if vbcc doesn't already have it. Not all of vbcc's warnings are activated by default. Have a look at the corresponding section in vbcc.doc. Q: Can you add precompiled header files? A: Currently vbcc uses a separate preprocessor which makes that feature impossible. When I find the time to complete the builtin preprocessor, I may add them. Q: How about adding a feature x to the compiler? A: If you think you have a good idea for a new feature, let me know. But the chances of getting it into vbcc depend on several factors: - Of course the importance/impact of the feature is a main factor. - Also, the amount of work to add it is crucial. - It should be portable to all host systems. - There are better chances if the feature is also portable to all target systems. - If it is target-specific it should be possible to add it by only changing the corresponding backend. I try to avoid target specific code anywhere else. - If possible the feature should comply with the ANSI/ISO standard. Q: I had a look at the source code of vbcc. Do you know what you're doing? A: Yes (mostly :-). Q: vbcc does not create executables but only assembly output. A: Don't call the compiler directly. Use the frontend vc. Q: When I use the optimizer vbcc uses very much memory and takes much longer to compile. A: This is normal. Especially with -O3. Q: But it needs very very much time and memory when optimizing. A: This is probably still normal. Global optimizing is not simple. Some things you can try: - Don't use the optimizer or at least use it only for time-critical functions. vbcc's code with default settings often is good enough. - Use a lower optimization level, e.g. -O rather than -O2 or -O3. - When using -O3 use lower settings for -inline-size and -unroll-size. - When using -O2 or -O3 use lower settings for -maxoptpasses. - Split up larger larger functions. The time and memory needed by the optimizer grows more than linear with the size of functions. So one large function takes longer to optimize than several small ones (unless they are inlined, of course). Q: I used the optimizer and the program got larger. A: This is normal. vbcc mainly optimizes for speed rather than size. Especially with -O3 the code may get much larger due to function-inlining and loop-unrolling. Q: I used the optimizer and the program got slower. A: This can happen sometimes. It is not always possible to decide whether a certain optimization is worthwile or not, so vbcc has to use certain heuristics. E.g. vbcc will assume that loops will be executed often and therefore try to reduce the amount of work to be done within the loop. The code outside the loop is considered less important. If the loop only gets executed very few times, the result might be worse than unoptimized code. Q: So what optimizations should I use? A: It's very hard to give a general answer. If possible, try them out. Q: vbcc generates rather bad code for my source. A: This cannot always be avoided. vbcc is far from perfect. Feel free to send me the code and explain what code you would have expected. But don't get your hopes up too high. Usually I already know the most important shortcomings of vbcc's code-generation, but fixing them often is not at all trivial and my time is very limited. Q: My program behaves differently when compiled with optimizations. A: Check if your program is really correct. The optimizer often exhibits bugs in programs. Note that the layout of code and data can be completely different when using the optimizer and that the optimizer works on a pretty large scope. Therefore the cause of the error might be very far from the location where the error occurs. If you think your program is correct, see BUGREPORTS. AMIGA RELATED QUESTIONS Q: When linking I get errors about __ieee not found. A: When using floating point math you have to link with a math-library. See vclib.doc. Q: Can vbcc generate code for 68020/30/40/60 and/or FPU? A: Yes, see vbccm68k.doc and vclib.doc. Q: Can vbcc generate inline-instructions for sin() etc. on 68881? A: Yes, have a look at vclib.doc. Q: Can vbcc generate code for ELF/V.4 PPC? A: Yes, use +ppc and have a look at readme.vbcc. Q: Can vbcc generate code for WarpOS PPC? A: Frank Wille is working on it. Q: Can code generated by vbcc be linked together with that of other Amiga compilers? A: Usually, yes. However there are some minor incompatibilities between several Amiga compilers. Try to avoid passing structures and short types (char, short, float). Also be careful with floating-point-arguments to varargs-function. Q: vbcc or some of the utilities crash on my machine. A: Is your stack set large enough? Otherwise see BUGREPORTS. Q: I tried to #include , or similar files and only get lots of errors. A: Those files are compiler-specific and do not belong to vbcc. To use library-functions, usually should be included. If you want vbcc to generate inline-library-calls you may include the files . But note that those are vbcc-specific and you have to use the ones that come with vbcc. Q: How can I use other shared libraries? A: Those libraries should come with a so-called fd-file (with an .fd-suffix). You have to create a link-library from those and link them to your program. See vbccm68k:doc/fd2lib.doc or vbccppc:doc/fd2libPPC.doc on how to create the library. Then copy the library to vlibm68k:foo.lib or vlibppc:libfoo.a and add -lfoo when linking with vc. Q: Can I write shared libraries with vbcc? A: Yes, there is an example (clib.lha) on aminet that shows how to write shared libraries for several compilers including vbcc. Q: I need some Unix/POSIX-functions vc.lib does not provide. A: You can compile your program to use ixemul.library. Have a look at machines/amiga68k/doc/ixemul.doc. Q: Programs using clock() don't work. A: clock() should return the time used by the program or -1 if this information is not available. On the Amiga it is not available so vc.lib always returns -1. You can link with extra.lib to get an alternative version of clock() that returns a value reflecting the current time. This will make most programs work but is not really what ANSI/ISO intends. Q: Do programs compiled with vbcc work with Kickstart 1.3 or earlier? A: Not by default. It could be done by modifying the linker-lines in vc.config and taking care of some other problems. BUGREPORTS If you have a bug-report, send it to volker@vb.franken.de and include at least the following information where applicable/available: - Configuration of the machine you are using, including OS-version, CPU-type and amount of RAM. - The version of vbcc you are using (type vbcc without arguments to get the version) and from where and when you got it. - All source files (and maybe data files) necessary to reproduce the problem. Try to isolate the problem as much as possible and trim it down as far as you can. If you give me a large source there is little chance I can tell if there is a problem with vbcc and fix it. - The exact command-line you use to compile (preferrably with the -v option) and the output during compilation. - If the problem occurs when running the program, a detailed description how to invoke it to reproduce the problem and a description of what happens, and why you think this is incorrect/what you think should happen instead. - If possible a commented assembly listing of the generated code with some annotations explaining the problem. Volker Barthelmann volker@vb.franken.de