Re: sinf compiler error I don't understand FIXED!!

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 3 April 2011 23:25, les <hlhowell@xxxxxxxxxxx> wrote:
> On Sun, 2011-04-03 at 00:13 +0100, Ian Malone wrote:
>> On 1 April 2011 23:29, les <hlhowell@xxxxxxxxxxx> wrote:

>> > Clearly sinf is recognized, and compiles and runs. ÂIt returns 1.000 as
>> > expected for M_PI/2. ÂBut the line that is commented out will not
>> > compile.

> The first response found the error -lm which fired up the linker with
> the module. ÂApparently the compiler auto replaced sinf(M_PI/2) with a
> constant and didn't throw the linker error, where as the second one put
> in the call to the math library and threw the error. ÂAdding -lm loads
> the library.
>
> Â Â Â ÂI was compiling as C, but thought the error might have come due to my
> miscalling gcc thus invoking the C++ compiler and missing something to
> call the correct sin function i.e. sin/sinf/sinl etc. ÂBut I had written
> good code, just misinterpreted the error and forgot the link argument.
> I guess the C++ form as you used probably seeks to find any libraries
> required by the code, preventing linker errors. ÂThat is probably a good
> thing.
>

An old favourite, I must have misread your post, because if I'd
thought you were compiling as C not C++ that would have been the first
thing to come to mind. libm is not linked in C unless explicitly
specified, but is always included in C++: difference in the languages.
The part where it replaces the call to sinf with a constant and masks
the error is particularly devious.

I think there have been suggestions that it's time to start having
libm linked in gcc by default as the space saving (its purpose a very
long time ago) is tiny.

-- 
imalone
-- 
users mailing list
users@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe or change subscription options:
https://admin.fedoraproject.org/mailman/listinfo/users
Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines


[Index of Archives]     [Older Fedora Users]     [Fedora Announce]     [Fedora Package Announce]     [EPEL Announce]     [EPEL Devel]     [Fedora Magazine]     [Fedora Summer Coding]     [Fedora Laptop]     [Fedora Cloud]     [Fedora Advisory Board]     [Fedora Education]     [Fedora Security]     [Fedora Scitech]     [Fedora Robotics]     [Fedora Infrastructure]     [Fedora Websites]     [Anaconda Devel]     [Fedora Devel Java]     [Fedora Desktop]     [Fedora Fonts]     [Fedora Marketing]     [Fedora Management Tools]     [Fedora Mentors]     [Fedora Package Review]     [Fedora R Devel]     [Fedora PHP Devel]     [Kickstart]     [Fedora Music]     [Fedora Packaging]     [Fedora SELinux]     [Fedora Legal]     [Fedora Kernel]     [Fedora OCaml]     [Coolkey]     [Virtualization Tools]     [ET Management Tools]     [Yum Users]     [Yosemite News]     [Gnome Users]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [Fedora Sparc]     [Libvirt Users]     [Fedora ARM]

  Powered by Linux