Thread: WIP: Command line calculator. New to C

  1. #16
    Registered User
    Join Date
    Sep 2017
    Posts
    93
    Now I'm running into a compile error when I declare an extern variable.

    I get this error from clang:
    Code:
    Undefined symbols for architecture x86_64:
      "_pmsdMath", referenced from:
          _funcPMSD in mathematics-99e99e.o
      "_pmsdNumber0", referenced from:
          _main in main-aa69d6.o
          _funcPMSD in mathematics-99e99e.o
      "_pmsdNumber1", referenced from:
          _main in main-aa69d6.o
          _funcPMSD in mathematics-99e99e.o
      "_pmsdTotal", referenced from:
          _funcPrintResult in mathematics-99e99e.o
    ld: symbol(s) not found for architecture x86_64
    clang: error: linker command failed with exit code 1 (use -v to see invocation)
    However, if I take out the extern variables, it compiles but doesn't print out any results.
    Last edited by Salem; 09-28-2017 at 10:22 AM. Reason: tags

  2. #17
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    37,408
    You haven't grasped this "no global variables and pass parameters instead" thing.

    Code:
    void funcPMSD( int pmsdMath ) {
        double pmsdTotal;
        if(pmsdMath == 1) {
    And main calls it with
    Code:
    funcPMSD(pmsd);
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #18
    Registered User
    Join Date
    Sep 2017
    Posts
    93
    Thank you! I don't know why my brain was making it so difficult to understand that but I got it!

    Thank you so much! It's working now!

    Thanks for helping with the breakthrough.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 12
    Last Post: 05-15-2017, 07:24 AM
  2. Command-line Calculator Error:
    By mmario10 in forum C Programming
    Replies: 2
    Last Post: 10-31-2011, 04:29 AM
  3. Problems building a "command-line" calculator
    By mmario10 in forum C Programming
    Replies: 6
    Last Post: 10-31-2011, 04:27 AM
  4. Command line how to handle optional command.
    By ovid in forum C++ Programming
    Replies: 1
    Last Post: 03-07-2010, 11:41 PM
  5. Command line
    By Dr Saucie in forum C Programming
    Replies: 6
    Last Post: 02-23-2010, 02:23 PM

Tags for this Thread