Sun Studio cc includes unused static inline functions in object file

While trying to compile some code originally compiled with GCC I run into a linking problem. My problem seems to be caused by that GCC does not include unused static inline functions in the object files while cc does. The following simple example can be used for illustrating this:
void foo();
static inline void bar()
  foo();
int main()
}This program compiles and links without any problems using GCC and Sun Studio 12 CC (the C++ compiler) but fails to link using Sun Studio 12 cc:
khepri%> cc staticinline.c
Undefined first referenced
symbol in file
foo staticinline.o
ld: fatal: Symbol referencing errors. No output written to a.out
It is probably fine of cc to include foo() in the object file (although not necessary?). My questions are:
1. Are there any reasons for why cc includes unused static inline functions in the object file while CC does not?
2. Are there any ways or options to tell cc to not include unused static inline functions in the object file?
In the example above this is easy to fix by just removing or #ifdef away the code but the original code where I have this problem is not maintained by me and the static inline functions are in header files that get included in multiple C files and in some of these the functions are used.
Thanks,
Olav

olavsa wrote:
1. Are there any reasons for why cc includes unused static inline functions in the object file while CC does not?
2. Are there any ways or options to tell cc to not include unused static inline functions in the object file?Removing dead code is an optimization, so you need at least -xO1 for that.

Similar Messages

  • "static inline" in headers cause multiply-defined errors linking git

    Hi,
    I'm trying to build git 1.6.2 with Sun Studio 12 on Solaris 10 SPARC (64bit), but I'm getting a "multiply-defined" error from ld when it tries to link any objects defined as "static inline" in the header files:
    git-compat-util.h
    ld: fatal: symbol `$XAbC.skip_prefix' is multiply-defined:
    (file libgit.a(date.o) type=FUNC; file libgit.a(parse-options.o) type=FUNC);
    ld: fatal: symbol `$XAbD.gitstrchrnul' is multiply-defined:
    (file libgit.a(date.o) type=FUNC; file libgit.a(parse-options.o) type=FUNC);
    ld: fatal: symbol `$XAbE.xsize_t' is multiply-defined:
    (file libgit.a(date.o) type=FUNC; file libgit.a(parse-options.o) type=FUNC);
    ld: fatal: symbol `$XAbF.has_extension' is multiply-defined:
    (file libgit.a(date.o) type=FUNC; file libgit.a(parse-options.o) type=FUNC);
    ld: fatal: symbol `$XAbG.sane_case' is multiply-defined:
    (file libgit.a(date.o) type=FUNC; file libgit.a(parse-options.o) type=FUNC);
    ld: fatal: symbol `$XAbH.strtoul_ui' is multiply-defined:
    (file libgit.a(date.o) type=FUNC; file libgit.a(parse-options.o) type=FUNC);
    ld: fatal: symbol `$XAbI.strtol_i' is multiply-defined:
    (file libgit.a(date.o) type=FUNC; file libgit.a(parse-options.o) type=FUNC);
    strbuf.h
    ld: fatal: symbol `$XAbJ.strbuf_swap' is multiply-defined:
    (file libgit.a(date.o) type=FUNC; file libgit.a(parse-options.o) type=FUNC);
    ld: fatal: symbol `$XAbK.strbuf_avail' is multiply-defined:
    (file libgit.a(date.o) type=FUNC; file libgit.a(parse-options.o) type=FUNC);
    ld: fatal: symbol `$XAbL.strbuf_setlen' is multiply-defined:
    (file libgit.a(date.o) type=FUNC; file libgit.a(parse-options.o) type=FUNC);
    ld: fatal: symbol `$XAbM.strbuf_addch' is multiply-defined:
    (file libgit.a(date.o) type=FUNC; file libgit.a(parse-options.o) type=FUNC);
    ld: fatal: symbol `$XAbN.strbuf_addstr' is multiply-defined:
    (file libgit.a(date.o) type=FUNC; file libgit.a(parse-options.o) type=FUNC);
    ld: fatal: symbol `$XAbO.strbuf_addbuf' is multiply-defined:
    (file libgit.a(date.o) type=FUNC; file libgit.a(parse-options.o) type=FUNC);
    hash.h
    ld: fatal: symbol `$XAbP.init_hash' is multiply-defined:
    (file libgit.a(date.o) type=FUNC; file libgit.a(parse-options.o) type=FUNC);
    cache.h:
    ld: fatal: symbol `$XAbQ.copy_cache_entry' is multiply-defined:
    (file libgit.a(date.o) type=FUNC; file libgit.a(parse-options.o) type=FUNC);
    ld: fatal: symbol `$XAbR.create_ce_flags' is multiply-defined:
    (file libgit.a(date.o) type=FUNC; file libgit.a(parse-options.o) type=FUNC);
    ld: fatal: symbol `$XAbS.ce_namelen' is multiply-defined:
    (file libgit.a(date.o) type=FUNC; file libgit.a(parse-options.o) type=FUNC);
    ld: fatal: symbol `$XAbT.create_ce_mode' is multiply-defined:
    (file libgit.a(date.o) type=FUNC; file libgit.a(parse-options.o) type=FUNC);
    ld: fatal: symbol `$XAbU.ce_mode_from_stat' is multiply-defined:
    (file libgit.a(date.o) type=FUNC; file libgit.a(parse-options.o) type=FUNC);
    ld: fatal: symbol `$XAbV.ce_to_dtype' is multiply-defined:
    (file libgit.a(date.o) type=FUNC; file libgit.a(parse-options.o) type=FUNC);
    ld: fatal: symbol `$XAbW.remove_name_hash' is multiply-defined:
    (file libgit.a(date.o) type=FUNC; file libgit.a(parse-options.o) type=FUNC);
    ld: fatal: symbol `$XAbX.object_type' is multiply-defined:
    (file libgit.a(date.o) type=FUNC; file libgit.a(parse-options.o) type=FUNC);
    ld: fatal: symbol `$XAbY.is_null_sha1' is multiply-defined:
    (file libgit.a(date.o) type=FUNC; file libgit.a(parse-options.o) type=FUNC);
    ld: fatal: symbol `$XAbZ.hashcmp' is multiply-defined:
    (file libgit.a(date.o) type=FUNC; file libgit.a(parse-options.o) type=FUNC);
    ld: fatal: symbol `$XAcA.hashcpy' is multiply-defined:
    (file libgit.a(date.o) type=FUNC; file libgit.a(parse-options.o) type=FUNC);
    ld: fatal: symbol `$XAcB.hashclr' is multiply-defined:
    (file libgit.a(date.o) type=FUNC; file libgit.a(parse-options.o) type=FUNC);
    ld: fatal: symbol `$XAcC.is_absolute_path' is multiply-defined:
    (file libgit.a(date.o) type=FUNC; file libgit.a(parse-options.o) type=FUNC);
    ld: fatal: symbol `$XAcD.hexval' is multiply-defined:
    (file libgit.a(date.o) type=FUNC; file libgit.a(parse-options.o) type=FUNC);
    ld: fatal: File processing errors. No output written to git-fast-import
    What's causing this & how do I prevent it from occurring?
    Thanks.
    -John

    Hi Fedor,
    My CFLAGS are: -xc99 -g -xs -fast -fsimple=1 -fns=no -xtarget=ultraT1 -xarch=sparcvis2 -m64
    -mt -xipo -xcode=pic32 -xpagesize=default -xlic_lib=sunperf
    I had to add -D_XPG6 to get the compile to start at all because of the following error: #error "Compiler or options invalid for pre-UNIX 03 X/Open applications and pre-2001 POSIX applications"
    My LDFLAGS are: -Wl,-ztext -Wl,-Bdirect -Wl,-zlazyload -Wl,-zcombreloc -Wl,-zignore
    Thanks.
    -John

  • GUI tools availabe with sun studio 11

    I have used sun workshop v5 for a good number of years and am happy with the GUI based tools I use for debugging C, Fortan and soon Ada code whcih link with dbx and emacs.
    I have had a trawl through the website but haven't found what I;m looking for.
    so the question is : what are the GUI based tools which I could use with sunstudio 11 which will give similar capability to that availabe with sun workshop v5 ?
    regards
    bladerunner

    I guess the base tools in Workshop 5 you mentioned are IDE, dbx. Sun Studio 11 has all of those functions which are much more far better than Workshop 5. The only missing from Sun Studio 11 IDE is project function. It will be back in next release. Take a look at Sun Studio matrix page to see which function is included in Sun Studio 11. The matrix page does not include WS 5 because this version is 5 years old. Here is the URL
    http://developers.sun.com/prodtech/cc/support/support_matrix.jsp
    -Ngoc

  • General and specific questions on the applicability of Sun Studio 11

    Hi. In an e-mail letter from Sun Microsystems I read about Sun Studio 11 to "utilize its record-setting parallelizing compilers." From this message I was attracted by the possibility of adding something like parallel processing, not by changing the processor (hardware), but by adding Sun-Studio-11 software to a Linux operating system. Now I already have a Fortran compiler, the Intel Fortran Compiler for Linux, which is free and can handle Cray-style pointers, a feature hard to find in a free Fortran compiler.
    1a. So for the most basic of questions, without having parallel-processing hardware, just an ordinary processor [a 1-GigaHertz (GHz) Advanced MicroDevices Duron central processing unit, in my case], is it possible to have parallel processing and thereby increase one's computing speed by installing Sun Studio 11 in a Linux operating system?
    1b. If so, by what factor could one expect the speed of computation to increase over not having Sun Studio 11 installed? (If the gain in speed is dependent on the type of computations being performed, I imagine possibly using a Fortran code to perform numerical calculations using and perhaps searching for minima or maxima in a two-or-more-dimensional surface. So please give me an idea of the sort of gain in speed one could expect for these two types of activites, calculations using formulas and searches for minima and maxima among already-computed quantities.)
    1c. Again if so, how could one just by adding software have parallel processing without two or more hardware processors? In other words, what is the basic working principle of the software to make the simultaneous performance of multiple tasks (multitasking or parallel processing) possible?
    2a. Does Sun Studio 11 include a Fortan compiler?
    2b. If so, must one use it to have parallel processing with Sun Studio 11?
    2c. Or will the Intel Fortran Compiler for Linux work with Sun Studio 11 to have a parallel processing capability?
    Concerning hardware requirements I read that Sun Studio 11 requires a minimum of 512 MegaBytes (MB) of memory, presumably Random Access Memory (RAM). My Hewlett-Packard, ZE1110, Pavilion, notebook computer has 256 MB of RAM, but is expandable to a maximum of 512 MB of RAM. So in this respect it is in principle at least technically possible for me to meet the minimum system requirement for Sun Studio 11 with my computer, if I choose to increase its RAM. Somehow accommodating the cost of such a RAM addition, including whether one may have to buy two, matching, 256-MB RAM modules or just presumably one additional 256-RAM module, is another requirement. But before spending money for such an upgrade, one should first thoroughly investigate other matters to determine if other things are going to work and to determine what gain, if any, one could expect in computing speed with Sun Studio 11 and an additional 256 MB of RAM; then decide, based on such data, whether the purchase is personally worth the money or not. That's one motivation behind this posting; another motivation is for me to learn some things.
    Lastly I would like to here thank whoever was thoughtful enough to provide the Sun Download Manager (SDM) 2.0, which allows the pausing and resumption of the 207-MB download studio11-lin-x86.tar.bz2 for the Linux version of the Sun Studio 11! Using a slow, dialup, Internet connection like mine having a maximum speed of 28.8 kilobits/second, this makes it possible to download that file over a number of Internet sessions instead of having to have an uninterrupted, 19-or-more-hour Internet session. Besides the invconvenience of tying up one's telephone line for that long a time, it might be even be difficult to have such an uninterrupted Internet session for that long a time. I have at least started such a download using the SDM 2.0 potentially over multiple Internet sessions. Whether or not I carry it out to completion could depend on whether everything looks good with Sun Studio 11 for my particular situation. Thanks in advance for your help.

    Thanks for both of your postings here. I'm mostly trying to learn something here.
    From Maxim Kartashev: "For example, if one thread (or process, or lwp) frequently performs an I/O operation, then the other thread (process, lwp) can utilize processor resources to perform, say, some computations while first one waits for operation to complete."
    I think I might understand what you meant above. I guess lwp in the above context stands for light-weight process. And I think you may be talking about a potential gain in speed with just one, ordinary processor. I guess you meant that one program, or perhaps group of programs, could perform input/output processes at the same time it is performing calculations because different parts of the processor are being used in these two groups of processes. Then on "while first one waits for operation to complete" I guess you meant that if the input/output operations finish before the computations finish, then thread 1 that was performing the input/output operations will have to wait until the current computations ordered by thread 2 are complete before thread 1 can utilize the computational resources for its own computations; i.e., two threads can't use the same computational resources of an ordinary processor at the same time. How is my thinking so far, Maxim, right, partly right, or all wrong?
    Now if the above thinking of mine is right, then it appears that one could have some gain in speed doing things like you suggest with just one, ordinary processor. And if so, I imagine that the gain could be a maximum of a factor of two for a program that requires spending as much time in input and output as it does in computation; i.e., keeping both the computational and input/output resources working all of the time without the input/output resources waiting on the computational resources or vice versa. How is my thinking here?
    If the above thinking is correct, just for purposes of discussion with just one, ordinary processor, not a dual processor, and a program which does nothing but computations there would be no gain in speed using Sun Studio 11 and a Fortran compiler over not using Sun Studio 11. In other words, to increase the speed of computation one would have to buy a faster computer, buy parallel processing hardware for an existing computer and use parallel-processing software, or somehow figure out how to harness two or more computers to work for you at the same time with instructions from one piece or perhaps set of pieces of code set up for parallel processing using two or more different computers. The latter case would be a computer analogue or "two 'heads' are better than one," not human heads, but computers. How is my thinking here?
    Here I am still assuming that it is possible for one processor to be used to do two different kinds things at once. However, I don't see how one Fortran program could instruct two things to be done at once. This is because I have not seriously studied parallel processing, I suppose. That is I am used to a sequential set of instructions that proceed from top to botton down the lines of code; i.e., one instruction or line of code can't be executed until the line of code before it has been completely executed. That is the computing "world" with which I am familiar. So how about someone here teaching me with an example of parallel-processing Fortran code how parallel processing works, explaining what instruction or group of instructions tells the computer to execute input and computational instructions at the same time?
    Based on the encouraging information from one or more other people I have been able to use the Intel Fortran for Linux 8.1.024, if I remember correctly, in a computer with a 1-GigaHertz (GHz), Advanced MicroDevices (A.M.D.), Duron Processor. So this is at least one case where it is not essential to have an Intel processor to use the Intel Fortran Compiler for Linux 8.1.024.
    Is the Sun Fortran compiler free for personal use? And can it handle Cray-style pointers?

  • Sun Studio in ClearCase?

    Hello all,
    we want to import the Sun Studio 8 C++ distribution
    into ClearCase, in order to be able versionize it.
    I don't know if this is practical, but is it possible at
    all?
    In general, is Sun Studio, once installed in /opt
    relocatable to, lets say /vobs/compilers just
    by a 'cp -rp'? What happens with subsequent
    patches? Can /opt/SUNWspro be deinstalled
    afterwards?
    Any comments/experiences?

    we want to import the Sun Studio 8 C++ distribution
    into ClearCase, in order to be able versionize it.
    I don't know if this is practical, but is it possible
    at all?
    In general, is Sun Studio, once installed in /opt
    relocatable to, lets say /vobs/compilers just
    by a 'cp -rp'? Sun Studio is installed via packages, which go into a defined location, recorded in the package database on the computer. Patches are tied to the installation location. If you move an installation, it will not match the package database, and patching will probably be difficult or impossible.
    You can install Sun Studio where ever you want. If you want to move it to another directory on the same computer, you should completely uninstall it, then reinstall in the new location.
    Package discipline is sometimes a pain in the neck, but it is the mechanism that ensures a known and consistent state for an installation and its patches.
    Here is a possible workaround.
    Create a tarball of an existing Sun Studio installation. You can un-tar into some other location -- let's call it SS8. You can run Studio from SS8. You cannot patch the installation in SS8. You can patch the original installation, then create a new tarball for copying to SS8. (Patches sometimes have non-obvious effects, so create a complete tarball instead of just copying the files you think have changed.)
    A Sun Studio installation includes quite a number of symbolic links. The symbolic links are either relative, or point into fixed system directories like /usr/lib. Do not use tar's "h" option that follows symbolic links. You need to preserve the links in the new location.
    For the same reason, you should not use cp to copy an installation. You will get copies of files that should be symbolic links.

  • Sun Studio 12 Update 1 - Now Available!

    Sun Studio 12 Update 1, the latest release of Sun Studio Compilers and Tools, is now available for download:
    [http://developers.sun.com/sunstudio/|http://developers.sun.com/sunstudio/]
    Available on Solaris, the next-generation of Solaris, OpenSolaris, and the latest Linux distributions, feature highlights since Sun Studio 12 include:
    - C, C++ and Fortran compiler optimizations for the latest UltraSPARC and SPARC64-based architectures
    - C, C++ and Fortran compiler optimizations for the latest x86 architectures from Intel and AMD including SSSE3, SSSE4a, SSe4.1, SSE4.2 compiler intrinsics support
    - Compiler, debugger, and profiling support for OpenMP 3.0
    - Profiling of distributed MPI-based applications
    - DLight - New tool for unified application and system profiling using Dynamic Tracing (DTrace) technology on Solaris platforms
    - dbxTool - New stand-alone graphical debugger
    - Highly tuned and parallelized scientific libraries, including ScaLAPACK
    - Update IDE based on NetBeans 6.5.1 software
    For more information, visit the Sun Studio 12 Update 1 Features page: [http://developers.sun.com/sunstudio/features/index.jsp|http://developers.sun.com/sunstudio/features/index.jsp]
    For the latest documentation, visit: [http://developers.sun.com/sunstudio/documentation/ss12u1/index.jsp|http://developers.sun.com/sunstudio/documentation/ss12u1/index.jsp]
    Share your experience with us by participating in the Sun Studio Blogging Contest: [http://developers.sun.com/sunstudio/community/campaigns/blogcontest_062009/welcome.jsp|http://developers.sun.com/sunstudio/community/campaigns/blogcontest_062009/welcome.jsp]

    >
    Run Sun Studio 12 (wait, this is Netbeans?):*"sunstudio", the IDE, is based on NetBeans cnd.
    run this command in any terminal (I have no idea what the & does):
    sunstudio &
    The & causes the process to be started in the background (and that's the background in the process sense, not the window manager sense). Otherwise the IDE will start, and as long as it runs, you won't be able to interact with the terminal where you launched the application [unless you do something like hit "ctrl-z", which will suspend the IDE, and then type "bg" to background it].
    Paul

  • Installing Javacomm in Sun Studio One?

    Is it possible to use javacomm with sun studio one?

    Ofcourse, it's just a JAR file like any other. Just mount the JAR file in Sun One Studio. Read the documentation (help pages) of Sun One Studio.
    Jesper

  • What Sun Studio 12 patches are included in Sun Studio 12 Update 1?

    I can't seem to find a bug list or patch list for Sun Studio 12 Update 1. Can someone provide a link or list of what was fixed?
    Secondary, how do I know I have Sun Studio 12 Update 1 installed? Does CC -V say 5.9.1?
    -kto

    I'm not sure about your bug list or patch list question, but on your second question you can use the "version" command.
    Just point it at the Sun Studio component you want to check. So for the CC compiler :
    % version sunstudio12.1/bin/CC
    version of "sunstudio12.1/bin/CC": Sun C++ 5.10 SunOS_sparc 2009/05/02
    You can also just type "version" and that will list all the
    components of the Sun Studio that are in your PATH, like so :
    % version
    Machine hardware: i86pc
    OS version: 5.10
    Processor type: i386
    Hardware: i86pc
    The following components are installed on your system:
    Sun Studio 12 update 1
    Sun Studio 12 update 1 C Compiler
    Sun Studio 12 update 1 C++ Compiler
    Sun Studio 12 update 1 Tools.h++ 7.1
    Sun Studio 12 update 1 C++ Standard 64-bit Class Library
    Sun Studio 12 update 1 Garbage Collector
    Sun Studio 12 update 1 Fortran 95
    Sun Studio 12 update 1 Debugging Tools (including dbx)
    Sun Studio 12 update 1 IDE
    Sun Studio 12 update 1 Performance Analyzer (including collect, ...)
    Sun Studio 12 update 1 Performance Library
    Sun Studio 12 update 1 Scalapack
    Sun Studio 12 update 1 LockLint
    Sun Studio 12 update 1 Building Software (including dmake)
    Sun Studio 12 update 1 Documentation Set

  • What Function/Features you want to have in next Sun Studio release?

    Hello,
    My name is Ngoc Nguyen, from Sun Studio product team. We just shipped Sun Studio 12 ML release (for C, C++, Fortran compiler) past few weeks. We start working on the next release. This is the right time for the community to tell us what feature you want to change or add into next release.
    HOW?
    Please use the following instruction. It seems long at start, but both you and Sun will get benefit from it on the long run. i.e: By this way, All of your suggestion/request will be logged into our worldwide database system and is assigned an Request for Enhancement (*RFE*) ID. Later You can view the progress of your suggestion/request by using this RFE ID.
    - Go to http://bugreport.sun.com/bugreport/
    Check the box at the bottom of the page
    Click on "Start a new Report"
    - Select the following
    Type = Request for Enhancement
    Product/Category = C/C++/Fortran Compilers and Tools - Misc
    Subcategory = C/C++/Fortran Compilers and Tools - Misc
    Release = Other
    Operating System = <your choice>
    - Click on "Continue"
    - On the next screen, you only need to fill out the required fields indicated by *.
    - The "Synopsis" field should be start with "VOC" word. VOC stands for "Voice of Customer". i.e: "VOC: I want to increase performance on xxxxx component".
    - The "Justification" field is important too. general statement like "It is important for us" may not look attractive.
    - After all, click on "Submit"
    This input collection process will last 10 days and will be ended on Wed Oct/31st.
    Looking forward to hear from you.
    Best Regards,
    Ngoc Nguyen
    IMPORTANT: Please don't post your suggestion/request on this forum thread because nobody will help you to log your suggestion into Sun System. Please use the method I outlined above.

    Hello,
    My name is Ngoc Nguyen, from Sun Studio product team. We just shipped Sun Studio 12 ML release (for C, C++, Fortran compiler) past few weeks. We start working on the next release. This is the right time for the community to tell us what feature you want to change or add into next release.
    HOW?
    Please use the following instruction. It seems long at start, but both you and Sun will get benefit from it on the long run. i.e: By this way, All of your suggestion/request will be logged into our worldwide database system and is assigned an Request for Enhancement (*RFE*) ID. Later You can view the progress of your suggestion/request by using this RFE ID.
    - Go to http://bugreport.sun.com/bugreport/
    Check the box at the bottom of the page
    Click on "Start a new Report"
    - Select the following
    Type = Request for Enhancement
    Product/Category = C/C++/Fortran Compilers and Tools - Misc
    Subcategory = C/C++/Fortran Compilers and Tools - Misc
    Release = Other
    Operating System = <your choice>
    - Click on "Continue"
    - On the next screen, you only need to fill out the required fields indicated by *.
    - The "Synopsis" field should be start with "VOC" word. VOC stands for "Voice of Customer". i.e: "VOC: I want to increase performance on xxxxx component".
    - The "Justification" field is important too. general statement like "It is important for us" may not look attractive.
    - After all, click on "Submit"
    This input collection process will last 10 days and will be ended on Wed Oct/31st.
    Looking forward to hear from you.
    Best Regards,
    Ngoc Nguyen
    IMPORTANT: Please don't post your suggestion/request on this forum thread because nobody will help you to log your suggestion into Sun System. Please use the method I outlined above.

  • Sun Studio 11 do not parse make output and create link to file?

    Hi,
    Running Sun Studio 11 and can only get file links in the output window when I run a make command that uses CC -g (debug option). We have integrated other tools into our make system (flexlint, cppUnit..) and even though we make sure that the syntax is exactly the same as the compiler output and matches regular expression under tools->options->building->make settings->error expression, it doesn't work. Why do you have to debug compile to get sun studio to create a file link in the output window? Doesn't sun studio just parse the text from the make command?
    example of flexlint output for which no link is created:
    "/vobs/project/oss/fm/fm4/fm-fmalib/fmbal/fmaaulib/src/FMA_List.cc", line 440: Error 84: sizeof object is zero or object is undefined'�
    example of make debug output for which we do get a link:
    "/vobs/project/oss/fm/fm4/fm-fmalib/fmbal/SunOS5.10/inc/FMA_alarm_record.hh", line 1310: Warning (Anachronism):Info "static" is not allowed and is being ignored.
    Regards,
    Ola

    I'd second Maxim's suggestion: try NetBeans 5.5 with C/C++ Development Pack. The official release of NetBeans C/C++ Development Pack 5.5 has happened a few days ago. You can download it from
    http://www.netbeans.info/downloads/all.php?b_id=2284
    Some of the changes between the beta3 build and FCS are:
    * Significant performance improvements in the code parser resulting in faster results in the Class View and Code Completion
    * Programs now run in an external terminal (system dependent) by default. This allows better input control
    * Significant performance improvement in the debugging module
    * Significant functionality improvement in the debugging module
    * New project type "C/C++ Project From Existing Code" which simplifies creating a project from existing code
    * Macro support in code completion
    * Hyperlink navigation for macro usages and #include directives
    * Reformat code
    * Code folding
    * Code completion
    All these features will appear in next Sun Studio release, so you can
    consider NetBeans C/C++ Development Pack 5.5 as a preview of new
    Sun Studio IDE.

  • Exception not always caught in Sun Studio 12

    Hi,
    We're using Sun Studio 12 (Sun C++ 5.9 SunOS_sparc Patch 124863-01 2007/07/25) on a Solaris 10 SPARC machine. In our applications an exception thrown is sometimes not caught in the try/catch statement and the program continues at an outer catch statement (which usually leads to the program exiting). So far I've not been able to reduce the code down to a simple example and I don't yet know what conditions causes this behaviour.
    In general the code has a big try/catch statement in main. Somewhere deep in the code there is a second try/catch statement which protects against a piece of code which we know may throw an exception. This is usually a smart pointer being dereferenced. The act of dereferencing the smart pointer in turn causes an exception to be thrown which is caught internally in a third try/catch inside the dereference code. The exception is successfully caught and some clean up is done. Then the exception is re-thrown by either using a throw; statement or a new throw xmsg("...");. All our exceptions are always of type xmsg which simply takes a string argument.
    When the problem manifests itself the second try/catch is ignored and the re-thrown exception is instead caught in the outer catch statement in main which causes the program to log an error and exit.
    We have lots of code which is structured the same way and the same style of code works in many cases only to fail in some specific case. It's an elusive problem because the problem moves around and it also depends on how the program is compiled. It only seems to happen when compiled in debug mode. If I compile with -xO4 the problem seems to go away.
    The problem also goes away or moves to a different place if the code has changed somewhere between compiles, i.e. some other developer has modified some code, not necessarily in the same are where the problem originally happened.
    One thing we have is a function we call DoThrow (used to suppress a warning on an older compiler) defined like this:
    void DoThrow(const std::string& msg)
      throw xmsg(msg);
    }As an experiment I replaced the call to DoThrow with a straight throw xmsg(...) at a place where the first exception was thrown and the problem went away. I'm not sure if removing the call to DoThrow fixed the problem or if the minor restructuring of the code was enough to move the problem elsewhere.
    For production releases we still use WorkShop 6, update 2 which does not have any problems like this. We really would like to upgrade to Sun Studio 12 because it's a much better compiler over all. We can't upgrade until we feel confident we have a workaround.
    Does anyone have any thoughts on what might be wrong or any ideas on what I can do to narrow down the problem?
    Thanks,
    Krister

    Many thanks. You've given me a few areas to focus on and I'll bring my house in order.
    The only external C++ library we depend on is STLport 5.0.2 which we compile ourselves. It's currently compiled with 5.3 on Solaris 8 and I will recompile it with 5.9 on Solaris 10. All other external libraries are C libraries. Our own code is put in static libraries and linked statically. I've read that exceptions thrown in shared libraries can be problematic.
    Your comment about complex conditional expressions (a ? f() : g()) is interesting. We've been bitten before by compiler bugs affecting those types of expressions. Destructors called twice or destructors called for temporaries never created. We may still have some conditional expressions like that.
    The exception is of type xmsg, defined this way:
    class xmsg
      public:
        xmsg(const char* s) : _msg(s) {}
        xmsg(const std::string& s) : _msg(s) {}
        const std::string& why() const { return _msg; }
      private:
        const std::string _msg;
    };There are three catch blocks involved and all the try/catch statement look like this:
    try
    catch(const xmsg& msg)
    }Here is a stack trace from dbx at the point where the exception is thrown the first time.
      [1] __exdbg_notify_of_throw(0xffbf4ae8, 0xffbf4ad0, 0x959b292c, 0xffff0000, 0x0, 0xfc00), at 0xfb6549b4
      [2] _ex_debug_handshake1(0x0, 0x101cb84, 0x1, 0x14ffc, 0xfb66a67c, 0xfb66ad38), at 0xfb655728
      [3] _ex_throw_body(0xfb66af80, 0x80b2ac, 0xfb66a67c, 0x14d9c, 0x0, 0xfb66af80), at 0xfb655934
      [4] __Crun::ex_throw(0xfb66afd0, 0x1460bf8, 0x7ead20, 0x0, 0x16538, 0x1), at 0xfb6558bc
    =>[5] TransportSource<User>::Activate(this = 0x1624810, r = CLASS, _ARG3 = CLASS), line 39 in "TransportSource.H"
      [6] Source<User>::DoActivate(this = 0x162486c, r = CLASS, e = CLASS), line 272 in "Factory.H"
      [7] BaseFactory::Load(this = 0x16020a8, e = CLASS), line 2799 in "BaseFactory.C"
      [8] GPAuthorizationSource::Load(this = 0x15d2440), line 110 in "GPAuthorization.C"
      [9] ExchangeServer::ExchangeServer(this = 0xffbfa95c, argc = 8, argv = 0xffbfbaec), line 380 in "exchangeServer.C"
      [10] main(argc = 8, argv = 0xffbfbaec), line 1525 in "exchangeServer.C"Here is the code for the Activate function in stack frame 5. The exception thrown is the second one.
        virtual T& Activate(const Reference& r, Exemplar<T>&)
          _transport->In().Write(r);
          DemarshallStream out;
          _transport->Method(Process::Activate, out);
          if(!out.Data())
         throw xmsg("Failed to call Activate on server " + _transport->Name());
          if(!out.GetBool())
         throw xmsg("Server returned error: " + out.GetString());
          const ClassHandle& h = out.GetClassHandle(&_connection);
          // don't need to pass refresh flag here because a call to Activate
          // means the object is being loaded for the first time.
          BaseExemplar* x = _handle.GetFactory().Demarshall(h, out, false,
         &_connection, this);
          BaseTransportSource::DoActivate(out);
          if(!x)
         throw xmsg("Failed to activate ref: " + r.ExternalValue());
          return static_cast<T&>(*x->GetInstance());
        }The exception is caught (frame 7 in the stack trace above) and re-thrown in the below code, at the last throw statement.
    void BaseFactory::Load(BaseExemplar& e)
      SourceMap::iterator p = _sources.find(&e._key->Type());
      if(p == _sources.end())
        throw xmsg("Factory<" + _handle.Name() + ">::Load - no source for: "
          + e._key->ExternalValue());
      AutoPointer<BaseGuard> g(Guard());
      std::list<BaseSource*>::iterator i = p->second.begin();
      while(true)
        try
          (*i)->_currentExemplar = &e;
          BO& x = (*i)->DoActivate(*e._key, e);
          (*i)->_currentExemplar = 0;
          if(!e._instance)
         e._instance = &x;
         Activate(e, ActivatedOld, 0);
          return;
        catch(const xmsg& msg)
          (*i)->_currentExemplar = 0;
          ++i;
          if(i == p->second.end())
         throw;
    }There is a second try/catch one level up (stack frame 8, the call to GPAuthorizationSource::Load). Here's a snippet of that piece of code.
        try
          const Exemplar<User>& user = UserFactory::Instance().CreateExemplar(
         *new UserReference(authorizationTable._login.Value()));
          *user;
        catch(const xmsg& msg)
          Logger::Instance() << LogHeader << MsgClass(MsgClass::Error)
         << "Error PMAutorizationSource: " << msg.why() << EndMsg;
        // ...I put a break-point in the catch block in the above code but I never hit the break point and the exception is caught in an outer try/catch, an error is printed and the program exits.
      try
      catch(const xmsg& msg)
        std::cerr << "ERROR: " << msg.why() << std::endl;
      }I'm sorry I have not yet been able to produce a smaller example that can be compiled and tested in isolation. I know that's important in order to track down the problem. It seems like the smallest change in seemingly unrelated parts of the code makes the problem come or go.

  • Strange C++ error when using newer Sun Studio compiler

    My company has just set up a new build machine for our product. We have gone from
    this version: CC: Sun C++ 5.7 Patch 117830-11 2007/04/04
    to this one: CC: Sun C++ 5.9 SunOS_sparc Patch 124863-01 2007/07/25
    we have also upgraded the OS (solaris/sparc). I think the new one has gcc but the old one doesn't (we don't use it).
    and now I am getting this error:
    "/opt/SUNWspro/prod/include/CC/./new", line 32: Error, badextlnk: operator new(unsigned) was declared before with a different language.
    "/opt/SUNWspro/prod/include/CC/./new", line 35: Error, badextlnk: operator delete(void*) was declared before with a different language.
    "/opt/SUNWspro/prod/include/CC/./new", line 37: Error, badextlnk: operator new[](unsigned) was declared before with a different language.
    "/opt/SUNWspro/prod/include/CC/./new", line 40: Error, badextlnk: operator delete[](void*) was declared before with a different language.
    "/opt/SUNWspro/prod/include/CC/./new", line 53: Error, badollnk: Only one of a set of overloaded functions can be extern "C".
    "/opt/SUNWspro/prod/include/CC/./new", line 54: Error, badollnk: Only one of a set of overloaded functions can be extern "C".
    "/opt/SUNWspro/prod/include/CC/./new", line 55: Error, badollnk: Only one of a set of overloaded functions can be extern "C".
    "/opt/SUNWspro/prod/include/CC/./new", line 56: Error, badollnk: Only one of a set of overloaded functions can be extern "C".
    "/opt/SUNWspro/prod/include/CC/Cstd/rw/iterator", line 106: Error, temnotexternc: Template declarations cannot have extern "C" linkage.
    "/opt/SUNWspro/prod/include/CC/Cstd/rw/iterator", line 169: Error, temnotexternc: Template declarations cannot have extern "C" linkage.
    "/opt/SUNWspro/prod/include/CC/Cstd/rw/iterator", line 185: Error, temnotexternc: Template declarations cannot have extern "C" linkage.
    "/opt/SUNWspro/prod/include/CC/Cstd/rw/iterator", line 198: Error, temnotexternc: Template declarations cannot have extern "C" linkage.
    "/opt/SUNWspro/prod/include/CC/Cstd/rw/iterator", line 202: Error, temnotexternc: Template declarations cannot have extern "C" linkage.
    "/opt/SUNWspro/prod/include/CC/Cstd/rw/iterator", line 206: Error, temnotexternc: Template declarations cannot have extern "C" linkage.
    "/opt/SUNWspro/prod/include/CC/Cstd/rw/iterator", line 217: Error, badollnk: Only one of a set of overloaded functions can be extern "C".
    "/opt/SUNWspro/prod/include/CC/Cstd/rw/iterator", line 225: Error, temnotexternc: Template declarations cannot have extern "C" linkage.
    "/opt/SUNWspro/prod/include/CC/Cstd/rw/iterator", line 239: Error, temnotexternc: Template declarations cannot have extern "C" linkage.
    "/opt/SUNWspro/prod/include/CC/Cstd/rw/iterator", line 249: Error, temnotexternc: Template declarations cannot have extern "C" linkage.
    "/opt/SUNWspro/prod/include/CC/Cstd/rw/iterator", line 264: Error, temnotexternc: Template declarations cannot have extern "C" linkage.
    "/opt/SUNWspro/prod/include/CC/Cstd/rw/iterator", line 275: Error, temnotexternc: Template declarations cannot have extern "C" linkage.
    I have no idea what could be causing this. I can find one link to it on this forum: http://forums.sun.com/thread.jspa?messageID=9488983 . But the only answer to that query says it is the same as another bug which appears entirely different, not to mention being very old (while talking about an imminent fix), and being related to a different OS and (I think) a different version of sun studio (express vs. normal?).
    Any ideas? Could it be related to having gcc/g++ on the machine?

    Hi,
    I am also facing the same error while upgrading the Sun compiler description as below
    when I am compiling the cxx file on the system with compiler version (CC: Sun C++ 5.9 SunOS_sparc 2007/05/03) , I am facing the following error:-
    /opt/SUNWspro/bin/CC -dy -misalign -xcode=abs64 -xarch=v9 -D__EXTENSIONS__ -Dsun4_R5=1 -I. -Isun4_R5_v -I/home/as185259/ash_iadraid/ash_get_10/IA/PORT/include -I/home/as185259/ash_iadraid/ash_get_10/IA/WV/WV5.3.6-ncr0302/build/include/sun4_R5_v -I/app/oracle/product/10.2.0/client_1/sqllib/public -I/app/oracle/product/10.2.0/client_1/precomp/public -I/opt/informix/include -DSVR4 -O -g p -pta -c MContext.cxx -o sun4_R5_v/MContext.o || \
    (rm -f sun4_R5_v.d; false)CC: Warning: -xarch=v9 is deprecated, use -m64 to create 64-bit programs
    "/home/as185259/ash_iadraid/ash_get_10/IA/WV/WV5.3.6-ncr0302/build/include/sun4_R5_v/ssmalloc.h", line 97: Error: Only one of a set of overloaded functions can be extern "C".
    "/home/as185259/ash_iadraid/ash_get_10/IA/WV/WV5.3.6-ncr0302/build/include/sun4_R5_v/ssmalloc.h", line 99: Error: Only one of a set of overloaded functions can be extern "C".
    "/home/as185259/ash_iadraid/ash_get_10/IA/WV/WV5.3.6-ncr0302/build/include/sun4_R5_v/ssmalloc.h", line 101: Error: Only one of a set of overloaded functions can be extern "C".
    "/home/as185259/ash_iadraid/ash_get_10/IA/WV/WV5.3.6-ncr0302/build/include/sun4_R5_v/ssmalloc.h", line 102: Error: Only one of a set of overloaded functions can be extern "C".
    4 Error(s) detected.
    The same file with the same compilation command is getting compiled with compiler version CC: Sun WorkShop 6 update 2 C+ 5.3 2001/05/15 .
    Can anyone suggest what should be the resolution:-
    The code for the ssmalloc.h file is as under:-
    #ifndef SSMALLOC_H
    #define SSMALLOCH
    #include <stddef.h>
    #if defined(__sparcv9)
    namespace ssmalloc {
    #endif
    #if defined(__cplusplus)
    extern "C" {
    #endif
    The type for the malloc routine depends on
    the compiler and library that you are using.
    #if defined(hpux) || defined(sun4_R5) || defined(__GNUC_) || defined(_OS2_)
    typedef void MALLOC_PTR;
    #else
    typedef char *MALLOC_PTR;
    #endif
    #if defined(_GNUG_)
    typedef size_t MALLOC_SIZE;
    #else
    typedef unsigned MALLOC_SIZE;
    #endif
    #if defined(sun4) && ! defined(_GNUG_)
    # define FREE_RETURNS int
    # define FREE_RETURN return 0
    #else
    # define FREE_RETURNS void
    # define FREE_RETURN return
    #endif
    // User-callable routines.
    // Note: memalign and valloc are broken in that they do not aling
    // memory on documented boundaries, and thus do not behave as described
    // on the "malloc" manual page. They simply call malloc.
    MALLOC_PTR malloc (MALLOC_SIZE size);
    FREE_RETURNS free (MALLOC_PTR data);
    MALLOC_PTR realloc (MALLOC_PTR data, MALLOC_SIZE size);
    MALLOC_PTR calloc (size_t nelem, size_t elsz);
    MALLOC_PTR valloc (unsigned size);
    MALLOC_PTR memalign (unsigned alignment, unsigned size);
    // This memory allocator supports memory allocation inside signal
    // handlers. For correct operation, the following functions must be
    // called upon entering and exiting signal handlers that allocate
    // memory.
    void ssmalloc_enter_signal_level();
    void ssmalloc_exit_signal_level();
    // Set this variable to not 0 (possibly in the debugger) if you want
    // to get malloc to check memory data structures very carefully as it
    // goes. This may be handy if you are trying to detect a memory
    // trasher.
    // It also causes ssmalloc to abort the program instead of returning
    // zero if memory runs out.
    extern int check_memory_very_carefully;
    #if defined(__cplusplus)
    #endif
    #if defined(__sparcv9)
    } // namespace ssmalloc {
    #endif
    #endif / SSMALLOCH */
    The Machine is
    root@ldg1-> uname -a
    SunOS ldg1 5.10 Generic_138888-03 sun4v sparc SUNW,Sun-Blade-T6320
    Thanks
    Vijay

  • Inline functions in C, gcc optimization and floating point arithmetic issues

    For several days I really have become a fan of Alchemy. But after intensive testing I have found several issues which I'd like to solve but I can't without any help.
    So...I'm porting an old game console emulator written by me in ANSI C. The code is working on both gcc and VisualStudio without any modification or crosscompile macros. The only platform code is the audio and video output which is out of scope, because I have ported audio and video witin AS3.
    Here are the issues:
    1. Inline functions - Having only a single inline function makes the code working incorrectly (although not crashing) even if any optimization is enabled or not (-O0 or O3). My current workarround is converting the inline functions to macros which achieves the same effect. Any ideas why inline functions break the code?
    2. Compiler optimizations - well, my project consists of many C files one of which is called flash.c and it contains the main and exported functions. I build the project as follows:
    gcc -c flash.c -O0 -o flash.o     //Please note the -O0 option!!!
    gcc -c file1.c -O3 -o file1.o
    gcc -c file2.c -O3 -o file2.o
    ... and so on
    gcc *.o -swc -O0 -o emu.swc   //Please note the -O0 option again!!!
    mxmlc.exe -library-path+=emu.swc --target-player=10.0.0 Emu.as
    or file in $( ls *.o ) //Removes the obj files
        do
            rm $file
        done
    If I define any option different from -O0 in gcc -c flash.c -O0 -o flash.o the program stops working correctly exactly as in the inline funtions code (but still does not crash or prints any errors in debug). flash has 4 static functions to be exported to AS3 and the main function. Do you know why?
    If I define any option different from -O0 in gcc *.o -swc -O0 -o emu.swc  the program stops working correctly exactly as above, but if I specify -O1, -O2 or O3 the SWC file gets smaller up to 2x for O3. Why? Is there a method to optimize all the obj files except flash.o because I suspect a similar issue as when compilling it?
    3. Flating point issues - this is the worst one. My code is mainly based on integer arithmetic but on 1-2 places it requires flating point arithmetic. One of them is the conversion of 16-bit 44.1 Khz sound buffer to a float buffer with same sample rate but with samples in the range from -1.0 to 1.0.
    My code:
    void audio_prepare_as()
        uint32 i;
        for(i=0;i<audioSamples;i+=2)
            audiobuffer[i] = (float)snd.buffer[i]/32768;
            audiobuffer[i+1] = (float)snd.buffer[i+1]/32768;
    My audio playback is working perfectly. But not if using the above conversion and I have inspected the float numbers - all incorrect and invalid. I tried other code with simple floats - same story. As if alchemy refuses to work with floats. What is wrong? I have another lace whre I must resize the framebuffer and there I have a float involved - same crap. Please help me?
    Found the floating point problem: audiobuffer is written to a ByteArray and then used in AS. But C floats are obviously not the same as those in AS3. Now the floating point is resolved.
    The optimization issues remain! I really need to speed up my code.
    Thank you in advice!

    Dear Bernd,
    I am still unable to run the optimizations and turn on the inline functions. None of the inline functions contain any stdli function just pure asignments, reads, simple arithmetic and bitwise operations.
    In fact, the file containing the main function and those functions for export in AS3 did have memset and memcpy. I tried your suggestion and put the code above the functions calling memset and memcpy. It did not work soe I put the code in a header which is included topmost in each C file. The only system header I use is malloc.h and it is included topmost. In other C file I use pow, sin and log10 from math.h but I removed it and made the same thing:
    //shared.h
    #ifndef _SHARED_H_
    #define _SHARED_H_
    #include <malloc.h>
    static void * custom_memmove( void * destination, const void * source, unsigned int num ) {
      void *result; 
      __asm__("%0 memmove(%1, %2, %3)\n" : "=r"(result) : "r"(destination), "r"(source), "r"(num)); 
      return result; 
    static void * custom_memcpy ( void * destination, const void * source, unsigned int num ) { 
      void *result; 
      __asm__("%0 memcpy(%1, %2, %3)\n" : "=r"(result) : "r"(destination), "r"(source), "r"(num)); 
      return result; 
    static void * custom_memset ( void * ptr, int value, unsigned int num ) { 
      void *result; 
      __asm__("%0 memset(%1, %2, %3)\n" : "=r"(result) : "r"(ptr), "r"(value), "r"(num)); 
      return result; 
    static float custom_pow(float x, int y) {
        float result;
      __asm__("%0 pow(%1, %2)\n" : "=r"(result) : "r"(x), "r"(y));
      return result;
    static double custom_sin(double x) {
        double result;
      __asm__("%0 sin(%1)\n" : "=r"(result) : "r"(x));
      return result;
    static double custom_log10(double x) {
        double result;
      __asm__("%0 log10(%1)\n" : "=r"(result) : "r"(x));
      return result;
    #define memmove custom_memmove
    #define memcpy custom_memcpy
    #define memset custom_memset
    #define pow custom_pow
    #define sin custom_sin
    #define log10 custom_log10 
    #include "types.h"
    #include "macros.h"
    #include "m68k.h"
    #include "z80.h"
    #include "genesis.h"
    #include "vdp.h"
    #include "render.h"
    #include "mem68k.h"
    #include "memz80.h"
    #include "membnk.h"
    #include "memvdp.h"
    #include "system.h"
    #include "loadrom.h"
    #include "input.h"
    #include "io.h"
    #include "sound.h"
    #include "fm.h"
    #include "sn76496.h" 
    #endif /* _SHARED_H_ */ 
    It still behave the same way as if nothing was changed (works incorrectly - displays jerk which does not move, whereby the image is supposed to move)
    As I am porting an emulator (Sega Mega Drive) I use manu arrays of function pointers for implementing the opcodes of the CPU's. Could this be an issue?
    I did a workaround for the floating point problem but processing is very slow so I hear only bzzt bzzt but this is for now out of scope. The emulator compiled with gcc runs at 300 fps on a 1.3 GHz machine, whereby my non optimized AVM2 code compiled by alchemy produces 14 fps. The pure rendering is super fast and the problem lies in the computational power of AVM. The frame buffer and the enulation are generated in the C code and only the pixels are copied to AS3, where they are plotted in a BitmapData. On 2.0 GHz Dual core I achieved only 21 fps. Goal is 60 fps to have smooth audio and video. But this is offtopic. After all everything works (slow) without optimization, and I would somehow turn it on. Suggestions?
    Here is the file with the main function:
    #include "shared.h"
    #include "AS3.h"
    #define FRAMEBUFFER_LENGTH    (320*240*4)
    static uint8* framebuffer;
    static uint32  audioSamples;
    AS3_Val sega_rom(void* self, AS3_Val args)
        int size, offset, i;
        uint8 hardware;
        uint8 country;
        uint8 header[0x200];
        uint8 *ptr;
        AS3_Val length;
        AS3_Val ba;
        AS3_ArrayValue(args, "AS3ValType", &ba);
        country = 0;
        offset = 0;
        length = AS3_GetS(ba, "length");
        size = AS3_IntValue(length);
        ptr = (uint8*)malloc(size);
        AS3_SetS(ba, "position", AS3_Int(0));
        AS3_ByteArray_readBytes(ptr, ba, size);
        //FILE* f = fopen("boris_dump.bin", "wb");
        //fwrite(ptr, size, 1, f);
        //fclose(f);
        if((size / 512) & 1)
            size -= 512;
            offset += 512;
            memcpy(header, ptr, 512);
            for(i = 0; i < (size / 0x4000); i += 1)
                deinterleave_block(ptr + offset + (i * 0x4000));
        memset(cart_rom, 0, 0x400000);
        if(size > 0x400000) size = 0x400000;
        memcpy(cart_rom, ptr + offset, size);
        /* Free allocated file data */
        free(ptr);
        hardware = 0;
        for (i = 0x1f0; i < 0x1ff; i++)
            switch (cart_rom[i]) {
         case 'U':
             hardware |= 4;
             break;
         case 'J':
             hardware |= 1;
             break;
         case 'E':
             hardware |= 8;
             break;
        if (cart_rom[0x1f0] >= '1' && cart_rom[0x1f0] <= '9') {
            hardware = cart_rom[0x1f0] - '0';
        } else if (cart_rom[0x1f0] >= 'A' && cart_rom[0x1f0] <= 'F') {
            hardware = cart_rom[0x1f0] - 'A' + 10;
        if (country) hardware=country; //simple autodetect override
        //From PicoDrive
        if (hardware&8)        
            hw=0xc0; vdp_pal=1;
        } // Europe
        else if (hardware&4)    
            hw=0x80; vdp_pal=0;
        } // USA
        else if (hardware&2)    
            hw=0x40; vdp_pal=1;
        } // Japan PAL
        else if (hardware&1)      
            hw=0x00; vdp_pal=0;
        } // Japan NTSC
        else
            hw=0x80; // USA
        if (vdp_pal) {
            vdp_rate = 50;
            lines_per_frame = 312;
        } else {
            vdp_rate = 60;
            lines_per_frame = 262;
        /*SRAM*/   
        if(cart_rom[0x1b1] == 'A' && cart_rom[0x1b0] == 'R')
            save_start = cart_rom[0x1b4] << 24 | cart_rom[0x1b5] << 16 |
                cart_rom[0x1b6] << 8  | cart_rom[0x1b7] << 0;
            save_len = cart_rom[0x1b8] << 24 | cart_rom[0x1b9] << 16 |
                cart_rom[0x1ba] << 8  | cart_rom[0x1bb] << 0;
            // Make sure start is even, end is odd, for alignment
            // A ROM that I came across had the start and end bytes of
            // the save ram the same and wouldn't work.  Fix this as seen
            // fit, I know it could probably use some work. [PKH]
            if(save_start != save_len)
                if(save_start & 1) --save_start;
                if(!(save_len & 1)) ++save_len;
                save_len -= (save_start - 1);
                saveram = (unsigned char*)malloc(save_len);
                // If save RAM does not overlap main ROM, set it active by default since
                // a few games can't manage to properly switch it on/off.
                if(save_start >= (unsigned)size)
                    save_active = 1;
            else
                save_start = save_len = 0;
                saveram = NULL;
        else
            save_start = save_len = 0;
            saveram = NULL;
        return AS3_Int(0);
    AS3_Val sega_init(void* self, AS3_Val args)
        system_init();
        audioSamples = (44100 / vdp_rate)*2;
        framebuffer = (uint8*)malloc(FRAMEBUFFER_LENGTH);
        return AS3_Int(vdp_rate);
    AS3_Val sega_reset(void* self, AS3_Val args)
        system_reset();
        return AS3_Int(0);
    AS3_Val sega_frame(void* self, AS3_Val args)
        uint32 width;
        uint32 height;
        uint32 x, y;
        uint32 di, si, r;
        uint16 p;
        AS3_Val fb_ba;
        AS3_ArrayValue(args, "AS3ValType", &fb_ba);
        system_frame(0);
        AS3_SetS(fb_ba, "position", AS3_Int(0));
        width = (reg[12] & 1) ? 320 : 256;
        height = (reg[1] & 8) ? 240 : 224;
        for(y=0;y<240;y++)
            for(x=0;x<320;x++)
                di = 1280*y + x<<2;
                si = (y << 10) + ((x + bitmap.viewport.x) << 1);
                p = *((uint16*)(bitmap.data + si));
                framebuffer[di + 3] = (uint8)((p & 0x1f) << 3);
                framebuffer[di + 2] = (uint8)(((p >> 5) & 0x1f) << 3);
                framebuffer[di + 1] = (uint8)(((p >> 10) & 0x1f) << 3);
        AS3_ByteArray_writeBytes(fb_ba, framebuffer, FRAMEBUFFER_LENGTH);
        AS3_SetS(fb_ba, "position", AS3_Int(0));
        r = (width << 16) | height;
        return AS3_Int(r);
    AS3_Val sega_audio(void* self, AS3_Val args)
        AS3_Val ab_ba;
        AS3_ArrayValue(args, "AS3ValType", &ab_ba);
        AS3_SetS(ab_ba, "position", AS3_Int(0));
        AS3_ByteArray_writeBytes(ab_ba, snd.buffer, audioSamples*sizeof(int16));
        AS3_SetS(ab_ba, "position", AS3_Int(0));
        return AS3_Int(0);
    int main()
        AS3_Val romMethod = AS3_Function(NULL, sega_rom);
        AS3_Val initMethod = AS3_Function(NULL, sega_init);
        AS3_Val resetMethod = AS3_Function(NULL, sega_reset);
        AS3_Val frameMethod = AS3_Function(NULL, sega_frame);
        AS3_Val audioMethod = AS3_Function(NULL, sega_audio);
        // construct an object that holds references to the functions
        AS3_Val result = AS3_Object("sega_rom: AS3ValType, sega_init: AS3ValType, sega_reset: AS3ValType, sega_frame: AS3ValType, sega_audio: AS3ValType",
            romMethod, initMethod, resetMethod, frameMethod, audioMethod);
        // Release
        AS3_Release(romMethod);
        AS3_Release(initMethod);
        AS3_Release(resetMethod);
        AS3_Release(frameMethod);
        AS3_Release(audioMethod);
        // notify that we initialized -- THIS DOES NOT RETURN!
        AS3_LibInit(result);
        // should never get here!
        return 0;

  • Sun Studio Compilers for Linux: Problems with undefined variables using CC

    I am experiencing the following errors below while trying to compile C++ programs using Sun C++ from the latest release of Sun Studio Compilers for Linux Alpha, on Red Hat Enterprise Linux 4 with kernel 2.6.9-34.EL and Ubuntu Breezy Badger 5.10 with kernel 2.6.12-10-686. I get the same exact errors on both OS's and on two different machines.
    root@ubuntu:/home/jc/cs225/Machine Problems/cs225/mp1/cs225_mp1# make
    CC -c -g string.cpp
    "/opt/sun/LinuxCompilers/sunstudiomars/prod/include/CC/Cstd/iosfwd", line 74: Error: mbstate_t is not defined.
    "/opt/sun/LinuxCompilers/sunstudiomars/prod/include/CC/Cstd/iosfwd", line 75: Error: mbstate_t is not defined.
    "/opt/sun/LinuxCompilers/sunstudiomars/prod/include/CC/Cstd/rw/traits", line 191: Error: "," expected instead of "state_type".
    "/opt/sun/LinuxCompilers/sunstudiomars/prod/include/CC/Cstd/rw/traits", line 194: Error: Use ";" to terminate declarations.
    "/opt/sun/LinuxCompilers/sunstudiomars/prod/include/CC/Cstd/rw/traits", line 261: Error: "," expected instead of "get_state".
    "/opt/sun/LinuxCompilers/sunstudiomars/prod/include/CC/Cstd/rw/traits", line 265: Error: Use ";" to terminate declarations.
    "/opt/sun/LinuxCompilers/sunstudiomars/prod/include/CC/Cstd/rw/traits", line 299: Error: "," expected instead of "state_type".
    "/opt/sun/LinuxCompilers/sunstudiomars/prod/include/CC/Cstd/rw/traits", line 302: Error: Use ";" to terminate declarations.
    "/opt/sun/LinuxCompilers/sunstudiomars/prod/include/CC/Cstd/rw/traits", line 410: Error: "," expected instead of "get_state".
    "/opt/sun/LinuxCompilers/sunstudiomars/prod/include/CC/Cstd/rw/traits", line 414: Error: Use ";" to terminate declarations.
    "/opt/sun/LinuxCompilers/sunstudiomars/prod/include/CC/Cstd/rw/traits", line 506: Error: The function "strstr" must have a prototype.
    "/opt/sun/LinuxCompilers/sunstudiomars/prod/include/CC/Cstd/rw/traits", line 523: Error: The function "strcspn" must have a prototype.
    "/opt/sun/LinuxCompilers/sunstudiomars/prod/include/CC/Cstd/rw/traits", line 529: Error: The function "strspn" must have a prototype.
    "/opt/sun/LinuxCompilers/sunstudiomars/prod/include/CC/Cstd/rw/rwlocale", line 125: Error: mbstate_t is not defined.
    "/opt/sun/LinuxCompilers/sunstudiomars/prod/include/CC/Cstd/rw/rwlocale", line 125: Error: Template parameter std::stateT requires a type argument.
    "/opt/sun/LinuxCompilers/sunstudiomars/prod/include/CC/Cstd/rw/rwlocale", line 130: Error: mbstate_t is not defined.
    "/opt/sun/LinuxCompilers/sunstudiomars/prod/include/CC/Cstd/rw/rwlocale", line 130: Error: Template parameter std::stateT requires a type argument.
    "/opt/sun/LinuxCompilers/sunstudiomars/prod/include/CC/Cstd/limits", line 214: Error: Template declarations cannot have extern "C" linkage.
    "/opt/sun/LinuxCompilers/sunstudiomars/prod/include/CC/Cstd/limits", line 221: Error: Template declarations cannot have extern "C" linkage.
    "/opt/sun/LinuxCompilers/sunstudiomars/prod/include/CC/Cstd/limits", line 277: Error: Template declarations cannot have extern "C" linkage.
    "/opt/sun/LinuxCompilers/sunstudiomars/prod/include/CC/Cstd/limits", line 335: Error: Template declarations cannot have extern "C" linkage.
    "/opt/sun/LinuxCompilers/sunstudiomars/prod/include/CC/Cstd/limits", line 392: Error: Template declarations cannot have extern "C" linkage.
    "/opt/sun/LinuxCompilers/sunstudiomars/prod/include/CC/Cstd/limits", line 443: Error: Template declarations cannot have extern "C" linkage.
    "/opt/sun/LinuxCompilers/sunstudiomars/prod/include/CC/Cstd/limits", line 504: Error: Template declarations cannot have extern "C" linkage.
    "/opt/sun/LinuxCompilers/sunstudiomars/prod/include/CC/Cstd/limits", line 558: Error: Template declarations cannot have extern "C" linkage.
    Compilation aborted, too many Error messages.
    make: *** [string.o] Error 1
    Except on ubuntu, it has one more error
    "/usr/include/wctype.h", line 47: Error: A declaration was expected instead of "}".
    and what is on line 47 is below
    __END_NAMESPACE_C99
    When I comment this line out, that particular error does not show up but still the other errors above still show up.
    From the testing I did, it appears to have these problems for most of the C++ programs I have written, especially the ones that involve object oriented programming. All programs that I wrote do not have these problems with g++ or Sun CC for Solaris. It does however work fine only for small fraction of the programs I have written. I dont quite understand why it works in some cases and others it doesnt, but I know for sure, that it should be working for all cases when Sun CC from Sun Studio 10 on Solaris 10 for X86 has no problems compiling the same programs.

    I tried workaround number 2 from the 3 choices that were listed by horsh. That fixes the mathcalls.h problem but still I have the following errors.
    jcurran2@ubuntu:~/cs225/Machine Problems/cs225/mp1/cs225_mp1$ make
    CC -c -g string.cpp
    "/usr/include/wctype.h", line 47: Error: A declaration was expected instead of "}".
    "/opt/sun/LinuxCompilers/sunstudiomars/prod/include/CC/Cstd/iosfwd", line 74: Error: mbstate_t is not defined.
    "/opt/sun/LinuxCompilers/sunstudiomars/prod/include/CC/Cstd/iosfwd", line 75: Error: mbstate_t is not defined.
    "/opt/sun/LinuxCompilers/sunstudiomars/prod/include/CC/Cstd/rw/traits", line 191: Error: "," expected instead of "state_type".
    "/opt/sun/LinuxCompilers/sunstudiomars/prod/include/CC/Cstd/rw/traits", line 194: Error: Use ";" to terminate declarations.
    "/opt/sun/LinuxCompilers/sunstudiomars/prod/include/CC/Cstd/rw/traits", line 261: Error: "," expected instead of "get_state".
    "/opt/sun/LinuxCompilers/sunstudiomars/prod/include/CC/Cstd/rw/traits", line 265: Error: Use ";" to terminate declarations.
    "/opt/sun/LinuxCompilers/sunstudiomars/prod/include/CC/Cstd/rw/traits", line 299: Error: "," expected instead of "state_type".
    "/opt/sun/LinuxCompilers/sunstudiomars/prod/include/CC/Cstd/rw/traits", line 302: Error: Use ";" to terminate declarations.
    "/opt/sun/LinuxCompilers/sunstudiomars/prod/include/CC/Cstd/rw/traits", line 410: Error: "," expected instead of "get_state".
    "/opt/sun/LinuxCompilers/sunstudiomars/prod/include/CC/Cstd/rw/traits", line 414: Error: Use ";" to terminate declarations.
    "/opt/sun/LinuxCompilers/sunstudiomars/prod/include/CC/Cstd/rw/traits", line 506: Error: The function "strstr" must have a prototype.
    "/opt/sun/LinuxCompilers/sunstudiomars/prod/include/CC/Cstd/rw/traits", line 523: Error: The function "strcspn" must have a prototype.
    "/opt/sun/LinuxCompilers/sunstudiomars/prod/include/CC/Cstd/rw/traits", line 529: Error: The function "strspn" must have a prototype.
    "/opt/sun/LinuxCompilers/sunstudiomars/prod/include/CC/Cstd/rw/rwlocale", line 125: Error: mbstate_t is not defined.
    "/opt/sun/LinuxCompilers/sunstudiomars/prod/include/CC/Cstd/rw/rwlocale", line 125: Error: Template parameter std::stateT requires a type argument.
    "/opt/sun/LinuxCompilers/sunstudiomars/prod/include/CC/Cstd/rw/rwlocale", line 130: Error: mbstate_t is not defined.
    "/opt/sun/LinuxCompilers/sunstudiomars/prod/include/CC/Cstd/rw/rwlocale", line 130: Error: Template parameter std::stateT requires a type argument.
    "/opt/sun/LinuxCompilers/sunstudiomars/prod/include/CC/Cstd/rw/codecvt", line 55: Error: mbstate_t is not defined.
    "/opt/sun/LinuxCompilers/sunstudiomars/prod/include/CC/Cstd/rw/codecvt", line 55: Error: Template parameter std::stateT requires a type argument.
    "/opt/sun/LinuxCompilers/sunstudiomars/prod/include/CC/Cstd/rw/codecvt", line 61: Error: "," expected instead of "state_type".
    "/opt/sun/LinuxCompilers/sunstudiomars/prod/include/CC/Cstd/rw/codecvt", line 63: Error: Use ";" to terminate declarations.
    Error: Cannot continue processing because of prior errors.
    Compilation aborted.
    make: *** [string.o] Error 1
    jcurran2@ubuntu:~/cs225/Machine Problems/cs225/mp1/cs225_mp1$
    Can someone please respond? There is more to the problem. Perhaps
    there are more glibc headers that have problems. In addition, if Sun wants to port the Sun Studio Compilers for linux to be stable on all linux distributions I suggest using VM ware and installing several linux distrobutions as virtual machines and testing this software on each virtual machine to see the problems that occur on each distribution. That way you might be able to uncover more problems to find a solution that will work best for portability on all linux distributions.

  • Problem in compilation using Sun Studio 11

    Hello,
    We are migrating from a Solaris 8 to a Solaris 10 OS. At the same ttime we are also migrating from Ingres 2.6 to Ingres 2006. As a part of the creation of teh development environment, we are recompiling all the codes on teh new OS. WE have installed teh Sun Studio 11 compiler for this purpose. When compiling some C codes, we are getting the following error:
    "am_xxxxxxxx.c", line 2596: warning: statement not reached
    "am_xxxxxxxx.c", line 2778: undefined symbol: i8
    "am_xxxxxxxx.c", line 2778: syntax error before or at: )
    "am_xxxxxxxx.c", line 2858: undefined symbol: i8
    "am_xxxxxxxx.c", line 2858: syntax error before or at: )
    "am_xxxxxxxx.c", line 2889: warning: implicit function declaration: IIresnext
    "am_xxxxxxxx.c", line 2891: warning: statement not reached
    "am_xxxxxxxx.c", line 2920: warning: statement not reached
    "am_xxxxxxxx.c", line 2931: undefined label: IIfdF1
    "am_xxxxxxxx.c", line 2931: undefined label: IIosl9139
    "am_xxxxxxxx.c", line 2931: undefined label: IIfdE1
    "am_xxxxxxxx.c", line 2931: cannot recover from previous errors
    cc: acomp failed for am_xxxxxxxx.c
    The command used for compiling is :
    cc -xarch=generic64 am_xxxxxxxx.c
    We have exported teh following:
    LD_LIBRARY_PATH_64=/usr/sfw/lib/sparcv9:/usr/local/lib/sparcv9:/usr/lib/sparcv9:/usr/openwin/lib/sparcv9:/usr/dt/lib/sparcv9:/opt/SUNWspro/lib/v9:/opt/SUNWspro/lib/v9:/eu/ingad/ingres/lib:/opt/oracle/lib:/usr/lib:/usr/ucblib:/usr/openwin/lib:/opt/SUNWspro/lib/:/opt/lib/cobol/coblib
    LD_LIBRARY_PATH=/opt/SUNWspro/lib/v9:/eu/ingad/ingres/lib:/eu/ingad/ingres/lib:/opt/oracle/lib:/usr/lib:/usr/ucblib:/usr/openwin/lib:/opt/SUNWspro/lib/:/opt/lib/cobol/coblib
    CXXFLAGS=-fast -xarch=v9b
    CFLAGS=-fast -xarch=v9b
    LDFLAGS=-L/usr/sfw/lib/sparcv9 -L/usr/lib/sparcv9 -R/usr/sfw/lib/sparcv9 -R/usr/lib/sparcv9
    We are struggling with this issue for the last one week. Can someone please help me with this issue?
    Could this be because the 64 bit library files are not installed? Please help.
    Aneesha

    The LD_LIBRARY_PATH environment variables determine where the runtime loader looks for shared libraries when you run an application. It is unlikely to be the source of compile-time errors.
    I suspect that doing two major changes at the same time has resulted in undefined names and other problems, probably due to missing or incorrect header inclusion. If possible, make one change at a time, either compile the old code on the new OS, or the new code on the old OS, and get that to work first.
    Check the Ingress documentation to see if you need to make source code changes when upgrading, and follow any recommendations there. You might also need to take up this problem with Ingress tech support.
    Regarding LD_LIBRARY_PATH, the best advice is usually "don't set it at all". For more on this topic, see this article:
    http://blogs.sun.com/rie/entry/tt_ld_library_path_tt
    Just to eliminate this as a possible build problem, try removing LD_LIBRARY_PATH and LD_LIBRARY_PATH_64 from your environment when building the program. Then modify the build process to set the executable runpath (-R option) to include the Ingress or Oracle libraries that need to be searched. You don't normally want to point into /usr/lib or into the compiler installation area.

Maybe you are looking for

  • Branch users in workgroup

    Hi! We have a branch connected to head office through IP-SEC tunnel without DC. Some of the users are laptop users and not connected to domain in head office. Is it possible to let them connect to head office network computers by NetBIOS names withou

  • Verify and repair permissions questions from wierdness

    Good morning I'm getting ready to upgrade to the snow cat but !!!! I went into disk utility with 10.5.8 to verify and repiar perimissions and I now have a list disk utility won't touch, eg, "permissions differ system/library/coreservice/airport base

  • Maintaining different values for Accounting Type (KOART)

    Hi experts, I have several accounting tcodes such as FBV0, FB03, FB08, FV65,FV60 in one parent role. FV60, FV65 are added to this role as FBV0 is checking internally for this authorization object.  All these tcodes share a same object  F_BKPF_KOA whi

  • Can Adobe convert ODF to PDF?

    Would like to convert my ODF files to Adobe PDF files. Would Adobe capable to convert the ODF files to PDF?

  • ADF connect with essbase

    plz give link for connecting essbase to Oracle ADF Give me the link. Thanks in advanced.