Signal fu-ion

Discussion in 'C' started by aVague, May 2, 2007.

  1. aVague

    aVague New Member

    Joined:
    May 2, 2007
    Messages:
    34
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    forex
    if somebody not knowing:
    signal functions are used to check operation like 0.1e-100/10e+100 for if the result out of range of double(float,...) or not
    from the theory :
    if we have digital forms of some numbers : 1110101010 and 1100101010 (same size ,of course) , while additioning them , we can have 1 , that is nowhere to write ( no place) , in this situation , proc-or put a flag on this operation and the signal func-ion read this flag...

    ok, now practise - example is:

    Code:
    #include<signal.h>
    #include<stdio.h>
    #include<stdlib.h>
    
    
    void hey()
           {
       printf("!Signal Error! Program interrupted.... Division by zero or overflow\n"); 
     getchar();
       exit(1);
    }
    int main()
    { 
    float z=0.1e-100,k=0.1e-100;
    signal(SIGFPE,hey);
    
    printf("%e",z/k);getchar();
                       } 
    working in Builder, but doesnt in Mvs( microsoft visual studio 2005),
    the questions are , what 1)why and maybe 2) what shall i do , to make it work?

    psss.
    if you have found a weird mistake in my grammar, dont be very surprised, cause i m from russia
     
  2. DaWei

    DaWei New Member

    Joined:
    Dec 6, 2006
    Messages:
    835
    Likes Received:
    5
    Trophy Points:
    0
    Occupation:
    Semi-retired EE
    Location:
    Texan now in Central NY
    Home Page:
    http://www.daweidesigns.com
    Signals are not a C thing. They are a platform-dependent thing. They are common in Unix-like systems, but not in Windows-type systems. Windows uses exceptions and messages differently. This is not to say that a signalling system could not be implemented on a Windows platform, but it would be an implementation specific thing.
     
    Last edited: May 2, 2007
  3. aVague

    aVague New Member

    Joined:
    May 2, 2007
    Messages:
    34
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    forex
    i see , so comiler gives me ways to declare signal(...) ( token from signal.h, visual studio 2005):


    "\Mvs\VC\include\signal.h(91): could be 'void (__cdecl *signal(int,void (__cdecl *)(int)))(int)'

    or 'void (__clrcall *signal(int,void (__clrcall *)(int)))(int)'

    or 'void (__clrcall *signal(int,int))(int)' "

    as i think, __cdel means c - declaration (or not?) , then comes sight * means ,that function has atomatically activation - my suggestion, then comes 1st argument - signal code, then comes some function with some special property(??what property??) or (in last variant) number of returning value ( equal to exit(that number)
    so that are my suggestions, how right they are?
     
  4. DaWei

    DaWei New Member

    Joined:
    Dec 6, 2006
    Messages:
    835
    Likes Received:
    5
    Trophy Points:
    0
    Occupation:
    Semi-retired EE
    Location:
    Texan now in Central NY
    Home Page:
    http://www.daweidesigns.com
    You will notice that the choice is made according to various preprocessor #if statements. This means that the interpretation will depend upon earlier preprocessor definitions. You will just have to chase all those down to see what your particular implementation (set of code) is doing. MSDN and Google should be able to handle that for you.
     
  5. aVague

    aVague New Member

    Joined:
    May 2, 2007
    Messages:
    34
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    forex
    thx, ll see
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice