• Lucid Dreaming - Dream Views




    Results 1 to 25 of 102
    Like Tree3Likes

    Thread: Ask me about C / C++

    Hybrid View

    1. #1
      Banned
      Join Date
      Apr 2007
      Location
      Out Chasing Rabbits
      Posts
      15,193
      Likes
      935
      That's because your syntax isn't quite right. Try this:

      Code:
      obj_files/AP_commons.o: AP_commons.cpp
         g++ AP_commons.cpp -g -O2 -Wall -MT obj_files/AP_commons.o -MD -MP -MF
      "./obj_files/AP_commons.Tpo" -c
      You can't specify where to compile to in the compile line itself, instead you tell it what output file the compile line belongs to.

      The syntax for compiling only goes:
      Code:
      Target: All dependancies (including libraries)
         compiler command

    2. #2
      Member
      Join Date
      May 2009
      Posts
      139
      Likes
      1
      Quote Originally Posted by ninja9578 View Post
      That's because your syntax isn't quite right. Try this:

      Code:
      obj_files/AP_commons.o: AP_commons.cpp
         g++ AP_commons.cpp -g -O2 -Wall -MT obj_files/AP_commons.o -MD -MP -MF
      "./obj_files/AP_commons.Tpo" -c
      You can't specify where to compile to in the compile line itself, instead you tell it what output file the compile line belongs to.

      The syntax for compiling only goes:
      Code:
      Target: All dependancies (including libraries)
         compiler command
      That one didn't work either g++ thought the *.0 and *.Tp0 were the input files and said it couldn't find them.

      I noticed that I couldn't find any place where it actually used the *.Tpo files, so I experimented this morning with a very simple command line of
      g++ AP_commons.cpp -c
      then moving the *.o files to obj_files manually. That cured most of the problems.

      But then I discovered that g++ couldn't find lroundf in the math library, even though it's there just as much as the other math functions the code uses. Fortunately it was simple to replace lroundf with the expression of (int)(n+0.5)

      After that, g++ couldn't find the system getopt.h, even though it's just as much there as any of the other system inlcudes. So I had to specify the absolute file location in the source code.

      But now, the g++ linking stage can't find getopt_long in getopt.h, even though it is there. And I have no idea how to fix that

    3. #3
      Member
      Join Date
      May 2009
      Posts
      139
      Likes
      1
      Ninja,
      since that package refused to compile, and unfortunately your advice didn't work, I spent yesterday afternoon coding a m4a tag dumping program from scratch in VB. It doesn't allow tag editting or anything, but it runs and serves the purpose I needed it for. So that's all taken care of. Maybe I'll even rewrite it in (working) C code when I have more energy, doing that should at least speed it up and allow me to port it into linux too.

    4. #4
      Banned
      Join Date
      Apr 2007
      Location
      Out Chasing Rabbits
      Posts
      15,193
      Likes
      935
      Yep, C code runs circles around VB code.

    5. #5
      Same great taste! Achievements:
      1 year registered 1000 Hall Points Veteran First Class
      Flavour of Night's Avatar
      Join Date
      Jan 2006
      LD Count
      Thousands.
      Gender
      Location
      East Tennessee
      Posts
      308
      Likes
      0
      Quote Originally Posted by ninja9578 View Post
      Yep, C code runs circles around VB code.
      Damned straight. Once compiled, does VB still toss in enormous wodges of non-essential crap from over-stuffed libraries?

    6. #6
      Banned
      Join Date
      Apr 2007
      Location
      Out Chasing Rabbits
      Posts
      15,193
      Likes
      935
      Not really, it's fairly compressed. There is some overhead, for instance, strings have about 4 levels of abstraction around then so every string manipulation requires about 4 times the work as in C++. VB is designed to be a learning tool, not a professional programming app, so the compiler is not very efficient at optimizing.

    7. #7
      Member Keresztanya's Avatar
      Join Date
      Mar 2008
      Gender
      Posts
      1,083
      Likes
      32
      What is the best book on C to read?

    8. #8
      Same great taste! Achievements:
      1 year registered 1000 Hall Points Veteran First Class
      Flavour of Night's Avatar
      Join Date
      Jan 2006
      LD Count
      Thousands.
      Gender
      Location
      East Tennessee
      Posts
      308
      Likes
      0
      Quote Originally Posted by ninja9578 View Post
      Not really, it's fairly compressed. There is some overhead, for instance, strings have about 4 levels of abstraction around then so every string manipulation requires about 4 times the work as in C++. VB is designed to be a learning tool, not a professional programming app, so the compiler is not very efficient at optimizing.
      I can still remember compiling "Hello World" for lulz in the old QB 4.5.. 14 Kb for: print "Hello World!"

      C compiled it much tighter only needing the include for stdio.h for the printf.

      Doing it in my old Borland Assembler only took a handful of bytes once compiled and linked to knock out a .com file with a label of:

      mssg db 'Hello World!",13,10,'$'

      then nothing more than:

      lea dx, mssg
      mov ah, 4ch
      Int 21


      Those DOS calls sure are handy. You could do it also with Int 9, but that's a bit more work.

      After awhile, you'd start to recognize the actual machine code for some of the calls and the like.

      Seems silly now, but, I can lay claim to having once owned a 10 meg HD, so the "who cares" attitude of today was a luxury unaffordable back then.

      code is fun, I've not bothered with it in years.. kinda makes me want to get my fingers back in shape.

      .

    Bookmarks

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •