Wikipedia:Reference desk/Archives/Computing/2015 May 23

Computing desk
< May 22 << Apr | May | Jun >> May 24 >
Welcome to the Wikipedia Computing Reference Desk Archives
The page you are currently viewing is an archive page. While you can leave answers for any questions shown below, please ask new questions on one of the current reference desk pages.


May 23 edit

clang help edit

[First, an apology. I could probably answer these questions myself with the help of the Clang User's Manual, but I have not yet succeeded in obtaining a copy of the Clang User's Manual.]

My Mac was recently upgraded to OS X 10.9, and I'm having a little difficulty adjusting. Among other things, when I went to reinstall the C compiler, I discovered that what Xcode now gives you is clang, not the gcc suite I'm used to. Here are some of the issues I'm having:

  1. The error messages are a little... verbose. Each error gives you three lines of output, like this:
        geowalkoutlines.c:66:4: error: non-void function 'walkoutlines' should return a value [-Wreturn-type]
            return;
            ^
    Lines two and three are nice touches, I suppose, but I don't need them and I'd like to turn them off. The man page suggests there are command line flags -fshow-source-location and -fcaret-diagnostics controlling these, but it looks like those flags turn the options on, while I'd like to turn them off. Anybody know how to do that? Alternatively, anybody know where these options are getting turned on by default, so I can tinker with the defaults?
  2. The error message I mentioned in #1 is an error, not a warning. Anybody know if there's a way to suppress it, or change it from an error to a warning? (I have lots of old code that uses "implicit void", and I might not want to change it all right away.)
  3. The error messages are also in color, which is, shall we say, hard on my eyes. Anybody know how to turn that off? (Setting TERM to "dumb" works, but it feels very wrong to be doing that for a C compiler.)
  4. Anybody know where the standard header files are? They're not in /usr/include any more.
  5. Anybody know what the debugger is? It's kind of a shock to get "gdb: command not found", and my code is, alas, still not perfect. (But I'm no real fan of gdb any more, so if clang has its own, presumably better debugger, I'm happy to give it a try.)

Thanks for any help! —Steve Summit (talk) 00:41, 23 May 2015 (UTC)[reply]

The clang user manual is at http://clang.llvm.org/docs/UsersManual.html. Command line flags can be turned off with "no-" added, eg -fno-caret-diagnostics. lldb is the debugger. I'm not an expert on any of this but a quick google turned this up for me.-gadfium 04:20, 23 May 2015 (UTC)[reply]
-fno-color-diagnostics will help your eyes. You might be able to avoid the "implicit void" error if you set -std=c99 (or even -std=c94 or -std=c89); it defaults to c11.-gadfium 04:29, 23 May 2015 (UTC)[reply]
I'm not a Mac owner, but the standard include files should be in /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include.-gadfium
Wow! Thanks very much for all that. You're just about five for five!
Only remaining question, which I'm not finding in the manual so far, is whether there's a way to tune the clang defaults on a global basis. I'm surprised if they left this out, since they seem to have done a super complete job on everything else. I may have to figure out a way to put in a feature request. —Steve Summit (talk) 12:19, 23 May 2015 (UTC)[reply]
If there's nothing in your makefile (or equivalent) setting the defaults, take a look at the CFLAGS environment variable (CXXFLAGS for C++ options). CFLAGS may be being set up in your .profile or whatever the equivalent of that is on a Mac.-gadfium 19:01, 23 May 2015 (UTC)[reply]
What do you mean by "implicit void"? It's undefined behavior to use the value of a function call that exited other than by a return statement with a value (C89, §3.6.6.4). Are you relying on implicit-int for your functions' return types and on the clients to ignore the values not being returned? --Tardis (talk) 14:15, 24 May 2015 (UTC)[reply]
Precisely. That's how we did it back in the day (the pre-C89-days, that is), when type void hadn't even been invented yet. —Steve Summit (talk) 21:05, 24 May 2015 (UTC)[reply]

How to boot from a USB stick with an IBM Thinkpad edit

I have an old laptop (an IBM Thinkpad). It is probably from 2005 or so. It is running Windows XP. I want to upgrade it to Windows 8. I have Windows 8 on a USB stick. How can I get my laptop to boot from the USB stick (so that I can install the Windows 8 onto the laptop)? Thanks. I am not that computer-savvy, so please don't get too technical with a lot of computer/technical jargon. Thanks. Joseph A. Spadaro (talk) 06:35, 23 May 2015 (UTC)[reply]

Hold the F12 key when you power on the computer until the "Boot Menu" appears, and choose USB. -- BenRG (talk) 07:02, 23 May 2015 (UTC)[reply]
I wouldn't be certain that a Thinkpad that old will be able to run Windows 8: getting the drivers for the network, sound and video cards, etc. may be non-trivial. It's also possible that it won't boot from USB. Even if it does, my Thinkpads from that era have USB 1 interfaces, which are very, very slow. It's likely to take a looong time to install from USB. If it was me (and I'm pretty technically savvy) I wouldn't bother to try.--Phil Holmes (talk) 10:28, 23 May 2015 (UTC)[reply]
Thanks. Yes, come to find out ... you are correct on all counts. (1) It will not boot from USB, after all. And (2) It will not be able to run Windows 8 at all, unless I upgrade some hardware first. I had not even thought of the slow USB 1 speed, either. Thanks. Joseph A. Spadaro (talk) 16:13, 23 May 2015 (UTC)[reply]
A Thinkpad from 2005 should support USB 2.0 ([1], [2]) and be able to boot from USB ([3]). The T43 was first released in 2005, with a 1600–2260 MHz CPU and a Radeon X300 GPU, and Windows 8.1 works on it ([4]). Computers haven't really gotten much better in the last decade. That said, depending on the actual model and year, you may be limited to Windows 7. -- BenRG (talk) 18:04, 23 May 2015 (UTC)[reply]
Thanks. I was only ball-parking when I said "2005". Although, I think that must be close. In any event, I called Microsoft. They stated that I need various minimum requirements (so much RAM, certain processor speed, so much hard disk space, etc.) in order to run Windows 8. And I do not have those minimum requirements. Also, my laptop will definitely not boot from USB. And, even if it did — which it doesn't — my hardware will take "accept" Windows 8. I tried to install Windowss 8 with a CD (instead of the USB stick). And I got an error message that says something along the lines of "this computer is not capable of installing Windows 8". Thanks. Joseph A. Spadaro (talk) 18:34, 23 May 2015 (UTC)[reply]
Most of the Windows 8 "requirements" are not really required. The problem with your machine may be that it doesn't support NX, which is a real requirement (but not required by Windows 7). You could check that with a tool like Speccy (on the CPU page, on the Instructions line, look for "NX" in the list).
What type of Thinkpad is it? The type is 7 digits and letters, possibly with a hyphen, e.g. 2373-91U. It should be printed on a sticker on the bottom, and Speccy may also tell you (under Model on the Motherboard page).
Or you could just give up. :-) -- BenRG (talk) 19:28, 23 May 2015 (UTC)[reply]
Thanks. I was wondering myself what type of Thinkpad it is. What make, model number, etc. I will have to look at the sticker on the bottom, as you suggested. I didn't know it would be listed there. But, just today, I brought my laptop to a computer repair shop. So, they still have it. I won't get it back for a few days (plus, there is the holiday intervening). And, whatever the issue is, when I tried to install Windows 8, I did get that error message that prevented me from going any further with the installation process. Joseph A. Spadaro (talk) 04:12, 24 May 2015 (UTC)[reply]
You might be better getting a second HDD for the computer, and installing Win8 on it. However, given the age of your laptop it probably uses PATA drives rather than the newer SATA drives, and PATA 2.5" drives might be hard to find. I don't think you can get adaptors for mobile drives, as there is less room for them. — Preceding unsigned comment added by LongHairedFop (talkcontribs) 10:46, 24 May 2015 (UTC)[reply]
Yeah. This is basically an "extra" piece of junk laptop. I have two good computers that I use daily, a desktop and a laptop. I am just giving this old clunker to my Dad, so he has something to fiddle around with. He will not use the computer extensively at all. But, I still want it to have Windows 8 instead of Windows XP, if at all possible. This is just a minor project and really not all that important to me. Thanks. Joseph A. Spadaro (talk) 16:12, 24 May 2015 (UTC)[reply]
I'd stick with XP on that laptop. It's going to work a lot better than Windows 8, even if you can find a way to load it. StuRat (talk) 21:07, 26 May 2015 (UTC)[reply]

If I have a computer with 127 usb devices connected (the maximum), what happens if I connect one more? Does the computer crash, give an error, do nothing? — Preceding unsigned comment added by 223.84.139.43 (talk) 17:34, 23 May 2015 (UTC)[reply]

I had the situation where I had more USB devices plugged in than the PC would allow, and it seemed to do as follows:
1) Ignored any new USB devices plugged in after the max was reached.
2) At boot time it apparently depended on the somewhat random boot order, resulting in a random USB device being ignored.
Of course, I can't guarantee that all PCs will behave the same way. StuRat (talk) 17:59, 23 May 2015 (UTC)[reply]
It probably depends on the computer and the specific USB host controller, but I suspect, most of the time it would do nothing, since it has run out of addresses to assign. The behaviour you describe, randomly deciding at boot up which it connects and which "miss out" makes sense, since the "boot up" time of each device would vary ever so slightly depending on power draw of the other devices etc, it would give enough "chaos" that the sequence in which they connect might change each time. I've only played a "bit" with usb controllers, but I get the impression that 127 was actually set as a limit that would "never be reached" in practice, so i'm not sure how well the limit is implemented. I suspect it's somewhat better than "crash the computer" but somewhat worse than "tell you the limit is reached and let you decide which device/s to ignore." Vespine (talk) 23:17, 25 May 2015 (UTC)[reply]
But I REALLY want to know what 127 USB devices you have plugged into your computer?? :) Also, by the by, I believe that the 127 limit is per CONTROLLER not per COMPUTER. A Computer can have more than one USB controller, in fact, these days I "think" it's pretty normal for most computers to have more than one USB controller (if you have USB3 controller you almost certainly also have a USB2 controller in the same computer), so I don't think there's anything stopping you from having more than 127 USB devices connected to one COMPUTER. Vespine (talk) 02:24, 26 May 2015 (UTC)[reply]