[Solved] Cannot use array with GCC

Because <array> got indirectly included from somewhere and you made the mistake of using namespace std, “array” in ErrorMessage refers to that name in the std namespace. That is a class template, not a type – hence the error message. Outside of value, its array is called value::array. (The typedef value::array array in value is … Read more

[Solved] if-else if ladder and Compiler Optimization

A large portion of this question will depend on what A, B and C really are (and the compiler will optimise it, as shown below). Simple types, definitely not worth worrying about. If they are some kind of “big number math” objects, or some complicated data type that needs 1000 instructions for each “is this … Read more

[Solved] In Makefiles GCC C programs, What are .d files and also what is a wildcard.? [closed]

These *.d files usually (and just conventionally) are make dependencies (but perhaps, and unlikely, D-language source code). The GCC compiler knows about -M (and related) preprocessor option, which asks make to …. Instead of outputting the result of preprocessing, output a rule suitable for make describing the dependencies of the main source file. With the … Read more

[Solved] Does AT&T syntax work on intel platform?

att vs intel syntax has been covered many times, here and other places. Assembly language is a language defined by the assembler, the particular program used to convert the ASCII assembly language into machine code for the particular target you are interested in. Unlike say a C or C++ compiler where there is a standard … Read more

[Solved] Should all code compiled for 32 bit machines be in 4 byte chunks?

Instruction size does not related to data or address bus size. Some 16-bit x86 CPUs have 3 totally different sizes with 8-bit data bus, 20-bit address bus and variable length instruction size. Modern 32-bit or 64-bit x86 have variable length instruction too for backward compatibility. Just look at the movl $0x542412e6, %eax and pushl 0x08048dd6 … Read more

[Solved] Compile c/c++ program using gcc [closed]

You should compile with g++, not gcc because it’s C compiler and <vector> is a C++ header file (not mentioning <vecotr> which is a typo) If you have to use C compiler, you have to remove all C++ dependencies from header files which are included from the C sources. solved Compile c/c++ program using gcc … Read more

[Solved] Assembly code fsqrt and fmul instructions

It looks like you are trying to do something similar to this: #include <stdio.h> double hullSpeed(double lgth) { double result; __asm__( “fldl %1\n\t” //st(0)=>st(1), st(0)=lgth . FLDL means load double float “fsqrt\n\t” //st(0) = square root st(0) “fmulp\n\t” //Multiplies st(0) and st(1) (1.34). Result in st(0) : “=&t” (result) : “m” (lgth), “0” (1.34)); return … Read more

[Solved] How does int a=65; printf(“%c”, a); work in c language in GCC?

The printf function has the following declaration: int printf(const char *format, …); The first argument must be a pointer to a char array, but any additional arguments can be of any type, so it’s not a compiler error if a format specifier mismatches the parameter (although it is undefined behavior). This still works however because … Read more

[Solved] Why does it return a random value other than the value I give to the function?

First of all, C functions are call-by-value: the int x arg in the function is a copy. Modifying it doesn’t modify the caller’s copy of whatever they passed, so your swap makes zero sense. Second, you’re using the return value of the function, but you don’t have a return statement. In C (unlike C++), it’s … Read more