dbl instead of double

This is a discussion on dbl instead of double within the C Programming forums, part of the General Programming Boards category; I am using a function written by someone else, that I am trying to use myself. It doesnt run successfully ...

  1. #1
    Registered User
    Join Date
    Apr 2008
    Posts
    190

    dbl instead of double

    I am using a function written by someone else, that I am trying to use myself. It doesnt run successfully with the GCC compiler, but I think the issues are solveable - with a little help:

    I have a file called mat.c that is included in my project it has a load of lines like this in it

    extern void vectorfprint(fd, n, x) ; //ベクトル x の出力

    about 20 of them.
    the function i am using calls this line

    vectorfprint(fd, nvar, simp[i]);

    however it states that it is an undefined reference to vectorfprint although mat.c is included in the project. How do i define it?
    Last edited by a.mlw.walker; 08-12-2011 at 05:47 AM.

  2. #2
    Registered User
    Join Date
    Jul 2011
    Location
    Bangalore,India
    Posts
    24
    Quote Originally Posted by a.mlw.walker View Post
    I am using a function written by someone else, that I am trying to use myself. It doesnt run successfully with the GCC compiler, but I think the issues are solveable - with a little help:
    The author keeps declaring double variables like this:
    Code:
    static dbl	(*objective)();
    
    static dbl	**simp, *fvalue;
    static dbl	*xcentroid;
    static dbl	fmean, fvar;
    
    static dbl	*xreflect,  *xcontract, *xexpand;
    static dbl	freflect, fcontract, fexpand;
    static dbl	al = 1, bt = 0.5, gm = 2;
    If i change the dbl to double it fixes the error. Was this an old way of declaring a double?

    The next time there is a problem is here:
    Code:
    static void initialize()
    {
    	int	i;
    
    	simp = alloc(dbl *, nvar+1);
    	for (i=0; i<=nvar; i++) {
    		simp[i] = alloc(dbl, nvar);
    	}
    	fvalue = alloc(dbl, nvar+1);
    
    	xcentroid = alloc(dbl, nvar);
    
    	xreflect  = alloc(dbl, nvar);
    	xcontract = alloc(dbl, nvar);
    	xexpand   = alloc(dbl, nvar);
    }
    if i change these dbl to double I get a new error (on each of the lines above with dbl) that says: expression expected before double, and gives me a warning, assingment makes pointer from integer without a cast.

    Please can someone help me get this function running.

    Thanks
    Maybe he had used a macro
    #define dbl double

    ...try adding it...

    EDIT:that made me think its a macro...but he edited the entire post....
    Last edited by subhash.rao; 08-12-2011 at 05:48 AM.

  3. #3
    Registered User manasij7479's Avatar
    Join Date
    Feb 2011
    Location
    Kolkata@India
    Posts
    2,490
    Quote Originally Posted by subhash.rao View Post
    Maybe he had used a macro#define dbl double...try adding it...
    If manually replacing didn't work, what makes you think that a macro would ?
    Manasij Mukherjee | gcc-4.8.2 @Arch Linux
    Slow and Steady wins the race... if and only if :
    1.None of the other participants are fast and steady.
    2.The fast and unsteady suddenly falls asleep while running !



  4. #4
    Registered User
    Join Date
    Jun 2005
    Posts
    5,879
    dbl has never been a standard way of declaring a double.

    From what you describe, dbl and alloc() are both non-standard macros in the original code - and dbl is more than just an alias for double. If the code was written by someone else, that person presumably had some files (a header, definitely, an associated source file, maybe) that are required for those macros to work.

    Do a search through all the files from this "someone else" to find out what dbl and alloc() really are. If that fails, something is missing from the files you have been given, and you will probably need to contact that "someone else".

    Incidentally, although I'm not saying definitively this is the case here, it is not unknown for an unethical programmer to attempt to make themselves indispensable to their employer. Such people use tricks in their code so it is very difficult for someone else to maintain. What you're describing is not completely inconsistent with such behaviour.
    Right 98% of the time, and don't care about the other 3%.

  5. #5
    Registered User
    Join Date
    Jul 2011
    Location
    Bangalore,India
    Posts
    24
    Quote Originally Posted by manasij7479 View Post
    If manually replacing didn't work, what makes you think that a macro would ?
    h edited the post...check post #2 please...

  6. #6
    Registered User
    Join Date
    Apr 2008
    Posts
    190
    Thanks guys yeah it was a macro. But it was very hard to find as the comments are in an eastern asian language so google wasnt putting it very high up the search!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Double liked list and double pointer
    By saillesh.sabari in forum C Programming
    Replies: 1
    Last Post: 12-10-2010, 10:03 AM
  2. Replies: 4
    Last Post: 10-31-2009, 07:18 PM
  3. Replace double with long double in all my code.
    By boyfarrell in forum C Programming
    Replies: 8
    Last Post: 04-30-2007, 04:17 PM
  4. Changing double time to double cost
    By chrismax2 in forum C++ Programming
    Replies: 2
    Last Post: 04-24-2004, 10:29 AM
  5. the diffrence between static double and double
    By sayeem81 in forum C Programming
    Replies: 6
    Last Post: 02-18-2002, 11:12 AM

Tags for this Thread


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21