Personal computing discussed

Moderators: renee, SecretSquirrel, just brew it!

  • 1
  • 2
  • 3
  • 4
  • 5
  • 10
 
whm1974
Emperor Gerbilius I
Topic Author
Posts: 6361
Joined: Fri Dec 05, 2014 5:29 am

Re: GGC errors with compiling C code.

Tue Nov 07, 2017 4:19 pm

DancinJack wrote:
whm1974 wrote:
just brew it! wrote:
The majority of the places I've worked discouraged (and in at least a couple of cases prohibited) the use of "hard tabs". Except in makefiles, of course, where they are an essential part of the syntax... :o

I wonder how many software installing from source issues are caused by beginners?


If I understand you correctly, not many because beginners usually don't get code into production.

I was refer to folks who install from source who are not programmers. Which I done before by strictly following well written instructions to the letter.
 
just brew it!
Administrator
Posts: 54500
Joined: Tue Aug 20, 2002 10:51 pm
Location: Somewhere, having a beer

Re: GGC errors with compiling C code.

Tue Nov 07, 2017 4:32 pm

Redocbew wrote:
just brew it! wrote:
Also correlated with Redocbew's post, no matter what style you choose, if you get a job developing professionally odds are good you'll be asked to change it anyway.

Yeah, it does tend to vary. I often use two-space indents when writing new code. In addition to stripping trailing whitespace, a features that converts tabs to space is useful also. For new projects which have mismatched indents(WTF! I still can't get over this one.) that's usually one of the first things I'll do. For large projects which are already entrenched it pays to just get used to whatever the current standard practice is and just go with that.

Some editors support special comments, which if placed somewhere in the source file will automatically configure the editor's tab settings. For example, with KDE's Kate editor:
/* kate: replace-tabs on; indent-width 4; */
would set my preferred indentation style, whereas:
/* kate: replace-tabs off; indent-width 4; */
would make it conform to morphine's style.

IIRC vi and emacs support similar constructs.
Nostalgia isn't what it used to be.
 
just brew it!
Administrator
Posts: 54500
Joined: Tue Aug 20, 2002 10:51 pm
Location: Somewhere, having a beer

Re: GGC errors with compiling C code.

Tue Nov 07, 2017 4:33 pm

whm1974 wrote:
DancinJack wrote:
whm1974 wrote:
I wonder how many software installing from source issues are caused by beginners?

If I understand you correctly, not many because beginners usually don't get code into production.

I was refer to folks who install from source who are not programmers. Which I done before by strictly following well written instructions to the letter.

I'm pretty sure you're part of a very small minority.
Nostalgia isn't what it used to be.
 
whm1974
Emperor Gerbilius I
Topic Author
Posts: 6361
Joined: Fri Dec 05, 2014 5:29 am

Re: GGC errors with compiling C code.

Tue Nov 07, 2017 4:37 pm

just brew it! wrote:
whm1974 wrote:
DancinJack wrote:
If I understand you correctly, not many because beginners usually don't get code into production.

I was refer to folks who install from source who are not programmers. Which I done before by strictly following well written instructions to the letter.

I'm pretty sure you're part of a very small minority.

I was using Linux Mint back when they didn't do in place upgrades. I wanted the latest kernel so...
 
just brew it!
Administrator
Posts: 54500
Joined: Tue Aug 20, 2002 10:51 pm
Location: Somewhere, having a beer

Re: GGC errors with compiling C code.

Tue Nov 07, 2017 4:42 pm

whm1974 wrote:
just brew it! wrote:
I'm pretty sure you're part of a very small minority.

I was using Linux Mint back when they didn't do in place upgrades. I wanted the latest kernel so...

Replacing the stock kernel that came with your distro puts you in the 1%, pretty much by definition. Especially for a "newbie oriented" distro like Mint.

I'm sure the percentage of people who do stuff like that is higher on a distro like, say, Debian.
Nostalgia isn't what it used to be.
 
Redocbew
Minister of Gerbil Affairs
Posts: 2495
Joined: Sat Mar 15, 2014 11:44 am

Re: GGC errors with compiling C code.

Tue Nov 07, 2017 4:46 pm

just brew it! wrote:
Some editors support special comments, which if placed somewhere in the source file will automatically configure the editor's tab settings.


Yeah, there's a package for Atom which does the same thing. If there's not too much cleanup required I'll often just go with that.
Do not meddle in the affairs of archers, for they are subtle and you won't hear them coming.
 
notfred
Maximum Gerbil
Posts: 4610
Joined: Tue Aug 10, 2004 10:10 am
Location: Ottawa, Canada

Re: GGC errors with compiling C code.

Tue Nov 07, 2017 8:08 pm

M-x untabify in (X)emacs :)
 
just brew it!
Administrator
Posts: 54500
Joined: Tue Aug 20, 2002 10:51 pm
Location: Somewhere, having a beer

Re: GGC errors with compiling C code.

Tue Nov 07, 2017 8:20 pm

https://stackoverflow.blog/2017/06/15/d ... -use-tabs/

(Sorry for dragging this thread further off-topic, I'll stop now.)
Nostalgia isn't what it used to be.
 
derFunkenstein
Gerbil God
Posts: 25427
Joined: Fri Feb 21, 2003 9:13 pm
Location: Comin' to you directly from the Mothership

Re: GGC errors with compiling C code.

Wed Nov 08, 2017 10:43 am

just brew it! wrote:
https://stackoverflow.blog/2017/06/15/developers-use-spaces-make-money-use-tabs/

(Sorry for dragging this thread further off-topic, I'll stop now.)

what about tabs that the IDE converts to spaces? Visual Studio (apparently) does this, and so do others.
I do not understand what I do. For what I want to do I do not do, but what I hate I do.
Twittering away the day at @TVsBen
 
morphine
TR Staff
Posts: 11600
Joined: Fri Dec 27, 2002 8:51 pm
Location: Portugal (that's next to Spain)

Re: GGC errors with compiling C code.

Wed Nov 08, 2017 10:46 am

derFunkenstein wrote:
just brew it! wrote:
https://stackoverflow.blog/2017/06/15/developers-use-spaces-make-money-use-tabs/

(Sorry for dragging this thread further off-topic, I'll stop now.)

what about tabs that the IDE converts to spaces? Visual Studio (apparently) does this, and so do others.

IDEs that do that automatically should be shot. Reiteration: the whole point of having tabs is that the IDE can display them as the user desires and everyone's happy.
There is a fixed amount of intelligence on the planet, and the population keeps growing :(
 
whm1974
Emperor Gerbilius I
Topic Author
Posts: 6361
Joined: Fri Dec 05, 2014 5:29 am

Re: GGC errors with compiling C code.

Wed Nov 08, 2017 10:51 am

morphine wrote:
derFunkenstein wrote:
just brew it! wrote:
https://stackoverflow.blog/2017/06/15/developers-use-spaces-make-money-use-tabs/

(Sorry for dragging this thread further off-topic, I'll stop now.)

what about tabs that the IDE converts to spaces? Visual Studio (apparently) does this, and so do others.

IDEs that do that automatically should be shot. Reiteration: the whole point of having tabs is that the IDE can display them as the user desires and everyone's happy.

What about just using a text editor like Gedit with syntax highlighting and line numbering and just compile the programs by hand using GCC and the like?
 
derFunkenstein
Gerbil God
Posts: 25427
Joined: Fri Feb 21, 2003 9:13 pm
Location: Comin' to you directly from the Mothership

Re: GGC errors with compiling C code.

Wed Nov 08, 2017 10:53 am

I cannot think of anything less fun than that. :lol:

incidentally that's why I hate web development.
I do not understand what I do. For what I want to do I do not do, but what I hate I do.
Twittering away the day at @TVsBen
 
DancinJack
Maximum Gerbil
Posts: 4494
Joined: Sat Nov 25, 2006 3:21 pm
Location: Kansas

Re: GGC errors with compiling C code.

Wed Nov 08, 2017 11:21 am

derFunkenstein wrote:
I cannot think of anything less fun than that. :lol:

incidentally that's why I hate web development.


That's how probably many, many of the devs in these forums learned (including me). For me it was Gentoo + Emacs + GCC/g++ (C/C++ in my case) I'm not sure you've made it to makefiles yet Funk, but compiling by typing it out everytime like this is rendered obsolete once you create one for your program.

g++ derFunkgotpwned.cpp  -o derFunkgotpwned
./ derFunkgotpwned
OMG FUNK GOT PWNED


Sweet example, huh?
i7 6700K - Z170 - 16GiB DDR4 - GTX 1080 - 512GB SSD - 256GB SSD - 500GB SSD - 3TB HDD- 27" IPS G-sync - Win10 Pro x64 - Ubuntu/Mint x64 :: 2015 13" rMBP Sierra :: Canon EOS 80D/Sony RX100
 
whm1974
Emperor Gerbilius I
Topic Author
Posts: 6361
Joined: Fri Dec 05, 2014 5:29 am

Re: GGC errors with compiling C code.

Wed Nov 08, 2017 11:27 am

DancinJack wrote:
derFunkenstein wrote:
I cannot think of anything less fun than that. :lol:

incidentally that's why I hate web development.


That's how probably many, many of the devs in these forums learned (including me). For me it was Gentoo + Emacs + GCC/g++ (C/C++ in my case)

g++ derFunkgotpwned.cpp  -o derFunkgotpwned
./ derFunkgotpwned
OMG FUNK GOT PWNED


Sweet example, huh?

While I may or may not switched to using an IDE such as Code::Blocks as I advance, I'm doing things the hard way on purpose so I can get the hard stuff out of way early so I can learn a lot more.
 
DancinJack
Maximum Gerbil
Posts: 4494
Joined: Sat Nov 25, 2006 3:21 pm
Location: Kansas

Re: GGC errors with compiling C code.

Wed Nov 08, 2017 11:36 am

whm1974 wrote:
While I may or may not switched to using an IDE such as Code::Blocks as I advance, I'm doing things the hard way on purpose so I can get the hard stuff out of way early so I can learn a lot more.


Believe me when I say, compiling and running programs from the command line and makefiles is not The Hard Part. Just keep pluggin' away.
i7 6700K - Z170 - 16GiB DDR4 - GTX 1080 - 512GB SSD - 256GB SSD - 500GB SSD - 3TB HDD- 27" IPS G-sync - Win10 Pro x64 - Ubuntu/Mint x64 :: 2015 13" rMBP Sierra :: Canon EOS 80D/Sony RX100
 
derFunkenstein
Gerbil God
Posts: 25427
Joined: Fri Feb 21, 2003 9:13 pm
Location: Comin' to you directly from the Mothership

Re: GGC errors with compiling C code.

Wed Nov 08, 2017 11:39 am

I didn't say bad, I said "not fun".
I do not understand what I do. For what I want to do I do not do, but what I hate I do.
Twittering away the day at @TVsBen
 
whm1974
Emperor Gerbilius I
Topic Author
Posts: 6361
Joined: Fri Dec 05, 2014 5:29 am

Re: GGC errors with compiling C code.

Wed Nov 08, 2017 11:44 am

DancinJack wrote:
whm1974 wrote:
While I may or may not switched to using an IDE such as Code::Blocks as I advance, I'm doing things the hard way on purpose so I can get the hard stuff out of way early so I can learn a lot more.


Believe me when I say, compiling and running programs from the command line and makefiles is not The Hard Part. Just keep pluggin' away.

Perhaps not, but my use of the CLI has gotten more rare over the years as Linux GUIs have become more capable and usable enough that is less need to even touch the CLI at all. So at this stage it has become harder to use the CLI as I had forgotten much. But yes I will keep plugging away.
 
DancinJack
Maximum Gerbil
Posts: 4494
Joined: Sat Nov 25, 2006 3:21 pm
Location: Kansas

Re: GGC errors with compiling C code.

Wed Nov 08, 2017 11:44 am

derFunkenstein wrote:
I didn't say bad, I said "not fun".


I'm just Funk'ing with you.
i7 6700K - Z170 - 16GiB DDR4 - GTX 1080 - 512GB SSD - 256GB SSD - 500GB SSD - 3TB HDD- 27" IPS G-sync - Win10 Pro x64 - Ubuntu/Mint x64 :: 2015 13" rMBP Sierra :: Canon EOS 80D/Sony RX100
 
derFunkenstein
Gerbil God
Posts: 25427
Joined: Fri Feb 21, 2003 9:13 pm
Location: Comin' to you directly from the Mothership

Re: GGC errors with compiling C code.

Wed Nov 08, 2017 11:46 am

I know, it's all good. :D
I do not understand what I do. For what I want to do I do not do, but what I hate I do.
Twittering away the day at @TVsBen
 
whm1974
Emperor Gerbilius I
Topic Author
Posts: 6361
Joined: Fri Dec 05, 2014 5:29 am

Re: GGC errors with compiling C code.

Wed Nov 08, 2017 4:13 pm

OK I'm still trying with the example from this page:
https://www.w3schools.in/c-tutorial/decision-making/if/
This will not compile:
#include<stdio.h>

main()
{
  int number;
  printf( & quot; Type a number: & quot;);
  scanf( & quot; % d & quot;, & amp; number);

  /* check whether the number is negative number */
  if (number & lt; 0) {
    /* If it is a negative then convert it into positive. */   
    number = -number; 
    printf( & quot; The absolute value is % d\ n & quot;, number);
  }
  grtch();
}

These are the errors I get with gcc ifcstatement.c in bash:
gcc cifstatement.c
cifstatement.c:3:1: warning: return type defaults to ‘int’ [-Wimplicit-int]
main()
^~~~
cifstatement.c: In function ‘main’:
cifstatement.c:6:13: error: ‘quot’ undeclared (first use in this function)
printf( & quot; Type a number: & quot;);
^~~~
cifstatement.c:6:13: note: each undeclared identifier is reported only once for each function it appears in
cifstatement.c:6:17: error: expected ‘)’ before ‘;’ token
printf( & quot; Type a number: & quot;);
^
cifstatement.c:7:16: error: expected ‘)’ before ‘;’ token
scanf( & quot; % d & quot;, & amp; number);
^
cifstatement.c:10:16: error: ‘lt’ undeclared (first use in this function)
if (number & lt; 0) {
^~
cifstatement.c:10:18: error: expected ‘)’ before ‘;’ token
if (number & lt; 0) {
^
cifstatement.c:13:19: error: expected ‘)’ before ‘;’ token
printf( & quot; The absolute value is % d\ n & quot;, number);
^
cifstatement.c:13:46: error: stray ‘\’ in program
printf( & quot; The absolute value is % d\ n & quot;, number);
^
cifstatement.c:15:3: warning: implicit declaration of function ‘grtch’; did you mean ‘getc’? [-Wimplicit-function-declaration]
grtch();
^~~~~
getc

This is driving nuts as I keep making changes but still will not compile. Do I need to install anything else to make this work?
 
Vhalidictes
Gerbil Jedi
Posts: 1835
Joined: Fri Jan 07, 2005 2:32 pm
Location: Paragon City, RI

Re: GGC errors with compiling C code.

Wed Nov 08, 2017 4:18 pm

While I'm the last person who should be looking at syntax and won't examine that part, IIRC the errors about "lt" (less-than?) and "grtch" not existing are representative of a missing function and/or library.

The compiler should in theory always know what you're talking about. It might be that you need more here than stdio.h

EDIT: Real programmers - feel free to laugh at my post, I'm just trying to point him in the right direction.
 
srg86
Gerbil Team Leader
Posts: 262
Joined: Tue Apr 25, 2006 7:57 am
Location: Madison, WI

Re: GGC errors with compiling C code.

Wed Nov 08, 2017 4:22 pm

whm1974 wrote:
This is driving nuts as I keep making changes but still will not compile. Do I need to install anything else to make this work?


I had to go to the link to see if it was any better, but that example looks seriously wrong.

* No quotations marks in printf?
* if (number & lt; 0) { ?????
* grtch(); I think is supposed to be getch();
* printf( & quot; The absolute value is % d\ n & quot;, number); $quot?

Not like any C code I've seen, I think that page has bad formatting or something.


If I can hazzard a guess:

printf("The absolute value is %d\n", number);
Intel Core i7 4790K, Z97, 16GB RAM, 128GB m4 SSD, 480GB M500 SSD, 500GB WD Vel, Intel HD4600, Corsair HX650, Fedora x64.
Thinkpad T460p, Intel Core i5 6440HQ, 8GB RAM, 512GB SSD, Intel HD 530 IGP, Fedora x64, Win 10 x64.
 
whm1974
Emperor Gerbilius I
Topic Author
Posts: 6361
Joined: Fri Dec 05, 2014 5:29 am

Re: GGC errors with compiling C code.

Wed Nov 08, 2017 4:26 pm

Vhalidictes wrote:
While I'm the last person who should be looking at syntax and won't examine that part, IIRC the errors about "lt" (less-than?) and "grtch" not existing are representative of a missing function and/or library.

The compiler should in theory always know what you're talking about. It might be that you need more here than stdio.h

Yeah I've gotten that 1t and grtch() don't exist and that is why I'm wondering if I need other stuff installed. Maybe I'll look at other manuals I found and start over. I put this free one on my Kindle so I can read it on my to and from groups:
https://www.thecrazyprogrammer.com/2015 ... nners.html
 
srg86
Gerbil Team Leader
Posts: 262
Joined: Tue Apr 25, 2006 7:57 am
Location: Madison, WI

Re: GGC errors with compiling C code.

Wed Nov 08, 2017 4:27 pm

whm1974 wrote:
Vhalidictes wrote:
While I'm the last person who should be looking at syntax and won't examine that part, IIRC the errors about "lt" (less-than?) and "grtch" not existing are representative of a missing function and/or library.

The compiler should in theory always know what you're talking about. It might be that you need more here than stdio.h

Yeah I've gotten that 1t and grtch() don't exist and that is why I'm wondering if I need other stuff installed. Maybe I'll look at other manuals I found and start over. I put this free one on my Kindle so I can read it on my to and from groups:
https://www.thecrazyprogrammer.com/2015 ... nners.html


I don't think you need anything more installed, the problem is that page rendering has mangled the code.
Intel Core i7 4790K, Z97, 16GB RAM, 128GB m4 SSD, 480GB M500 SSD, 500GB WD Vel, Intel HD4600, Corsair HX650, Fedora x64.
Thinkpad T460p, Intel Core i5 6440HQ, 8GB RAM, 512GB SSD, Intel HD 530 IGP, Fedora x64, Win 10 x64.
 
whm1974
Emperor Gerbilius I
Topic Author
Posts: 6361
Joined: Fri Dec 05, 2014 5:29 am

Re: GGC errors with compiling C code.

Wed Nov 08, 2017 4:30 pm

srg86 wrote:
whm1974 wrote:
Vhalidictes wrote:
While I'm the last person who should be looking at syntax and won't examine that part, IIRC the errors about "lt" (less-than?) and "grtch" not existing are representative of a missing function and/or library.

The compiler should in theory always know what you're talking about. It might be that you need more here than stdio.h

Yeah I've gotten that 1t and grtch() don't exist and that is why I'm wondering if I need other stuff installed. Maybe I'll look at other manuals I found and start over. I put this free one on my Kindle so I can read it on my to and from groups:
https://www.thecrazyprogrammer.com/2015 ... nners.html


I don't think you need anything more installed, the problem is that page rendering has mangled the code.

JHC, Learning C programming is hard enough as it is without bad webpage rendering mangling the code. :evil: :roll:

Edit: Crap like this almost made me give up Friday and Saturday. But like I said I'm going to learn C or bust and you have been a great help here. Maybe I should be reading a pdf instead?
 
Redocbew
Minister of Gerbil Affairs
Posts: 2495
Joined: Sat Mar 15, 2014 11:44 am

Re: GGC errors with compiling C code.

Wed Nov 08, 2017 4:37 pm

Let me ask, so I can get a better picture of what's going on: You're C code is using "&quot" in place of the single quote character? Or was that just an artifact of placing it within the browser?

If it does include the "&quot", then replace all the references for those, and the less than symbol, and any others you have in there with their actual characters. C is not a markup language like HTML, so there's no need to escape characters in this way in order for them to be interpreted properly.
Do not meddle in the affairs of archers, for they are subtle and you won't hear them coming.
 
whm1974
Emperor Gerbilius I
Topic Author
Posts: 6361
Joined: Fri Dec 05, 2014 5:29 am

Re: GGC errors with compiling C code.

Wed Nov 08, 2017 4:43 pm

Redocbew wrote:
Let me ask, so I can get a better picture of what's going on: You're C code is using "&quot" in place of the single quote character? Or was that just an artifact of placing it within the browser?

I have no idea. Looks like I'm going to have start learning from an PDF file or Ebook so I don't just give up. I have a few free ones downloaded. I'm going to start over with one of those. Now I'm wondering if I will be using a dozen or more manuals in learning C programming?
 
Redocbew
Minister of Gerbil Affairs
Posts: 2495
Joined: Sat Mar 15, 2014 11:44 am

Re: GGC errors with compiling C code.

Wed Nov 08, 2017 4:48 pm

That's what it looks like from the output from your compiler. Like srg86 said, the line that says

printf( & quot; The absolute value is % d\ n & quot;, number);


should read...

printf("The absolute value is %d\n", number);


Make similar substitutions elsewhere in your code, and that should help get rid of the bad formatting. Sometimes editors or browsers can do that while trying to be "smart" and attempting to retain the original formatting during a copy and paste. If you're not sure what substitutions to make, then you need a tutorial on common function calls like printf and scanf which have examples on their usage.
Do not meddle in the affairs of archers, for they are subtle and you won't hear them coming.
 
srg86
Gerbil Team Leader
Posts: 262
Joined: Tue Apr 25, 2006 7:57 am
Location: Madison, WI

Re: GGC errors with compiling C code.

Wed Nov 08, 2017 4:48 pm

Redocbew wrote:
Let me ask, so I can get a better picture of what's going on: You're C code is using "&quot" in place of the single quote character? Or was that just an artifact of placing it within the browser?

If it does include the "&quot", then replace all the references for those, and the less than symbol, and any others you have in there with their actual characters. C is not a markup language like HTML, so there's no need to escape characters in this way in order for them to be interpreted properly.


The w3c schools page he's copying from is replacing quotes and other characters with markup formatting I think (I'm not an HTML expert). Even when simply viewing the page its wrong (before even during the cut and paste).
Intel Core i7 4790K, Z97, 16GB RAM, 128GB m4 SSD, 480GB M500 SSD, 500GB WD Vel, Intel HD4600, Corsair HX650, Fedora x64.
Thinkpad T460p, Intel Core i5 6440HQ, 8GB RAM, 512GB SSD, Intel HD 530 IGP, Fedora x64, Win 10 x64.
 
Redocbew
Minister of Gerbil Affairs
Posts: 2495
Joined: Sat Mar 15, 2014 11:44 am

Re: GGC errors with compiling C code.

Wed Nov 08, 2017 4:50 pm

In that case, then yeah... go somewhere else and get a better tutorial. I've heard that w3schools wasn't a great resource, but I've never tried looking up one of their pages myself.
Do not meddle in the affairs of archers, for they are subtle and you won't hear them coming.
  • 1
  • 2
  • 3
  • 4
  • 5
  • 10

Who is online

Users browsing this forum: No registered users and 1 guest
GZIP: On