On 11 January 2011 09:09, Viesturs Lācis <[email protected]> wrote:
> Thanks!!! I had some problem with the line if (TYPE(t) = 0), when I > tried to sudo comp --install genserkins.c, but now it is o.k. for this > line. This is a very easy mistake to make in C (I do it fairly often) especially if you are used to other programming languages. C allows you to use an assignment as a value, ie if you assign a value to a variable, you can use that to assign a value to another variable. I once saw the line x = y = 0 used in a Quickbasic program by a C-coder. The result was not at all like he expected. In C the result is to set y to 0, then use that result (0) to assign to x. In Quickbasic the result is to evaluate (y = 0) as a true/false, and to give x the value of 0 or -1 accordingly. To check the value of a variable in C you use ==, to set the value you use =. In your if() statemtn there, you are assigning the value of 0 to TYPE(t), and for extra fun the if() statement will then continue on the basis that TYPE(t) is _not_ zero, as the assignment returns zero which means "false". To add to the complexity TYPE is (probably) a compiler macro, and the sequence "TYPE" will be text-substituted for the value defined in the header file. Be very careful with all-caps things in C, they rarely mean what they look to mean. > How do I get comp take also genserkins.h file? I tried to "comp > --install" it too, but terminal said "urecognized filetype for mode > install: 'genserkins.h' A .h file is a "header" file. They generally contain all the variable type declarations and macro substitutions. You add them to the source code with a #include statement. Bear in mind that as far as the compiler is concerned the header file is just pasted into the top of your source code file. That means that missed brackets or semicolons or braces in the header file will lead to wierd compiler errors being reported in the .c file (or even more confusingly in the .comp file). To include the genserkins.h file in your comp file use #include <genserkins.h> immediately after the ;; in your .comp file. -- atp "Torque wrenches are for the obedience of fools and the guidance of wise men" ------------------------------------------------------------------------------ Gaining the trust of online customers is vital for the success of any company that requires sensitive data to be transmitted over the Web. Learn how to best implement a security strategy that keeps consumers' information secure and instills the confidence they need to proceed with transactions. http://p.sf.net/sfu/oracle-sfdevnl _______________________________________________ Emc-developers mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/emc-developers
