CVI2010 sizeof-operator returns a wrong size of a struct

Hi,
in CVI2010 the sizeof-operator returns a wrong size of a struct, if it contains 4 bytes and other spaces. I suppose the adresses in the struct are also not like a c-programmer thinks. First a minimalistic code-example:
typedef struct
  char oneByte;
  long fourByte;
} TestStruct;
void main( )
    int size;
    TestStruct tmpVar;
    size = sizeof( TestStruct );
    // here is size=8 instead of 5
Since the last years and the last cvi-versions i had ever compiled
with the Borland-compiler, that returns the correct size. Because in CVI 2010 the Borland-compiler is
not included, i'm trying to use the standard build-In compiler. In my opinion the compiler seems to optimize the code in a way, my
project can't work with.
Because i'm reading the struct direct out of binary files i'm searching for a, not code based, solution.
Is it possible to deactivate the relevant optimization?
Thanks for your help and answer.
Markus
Solved!
Go to Solution.

The compiler can have different alignments for struct fields: a usual behaviour is to have them aligned on a 4-byte boundary, that is every field starts on a multiple of 4 bytes from the beginning of the struct in memory. This appears to be the behaviour of the compiler you are using at the moment, which returns 8 as the size of the struct having aligned the fields.
Struct alignment can be modified with an appropriate #pragma preprocessor instruction: adding #pragma pack (1); in your code instructs the compiler to pack structure fields without padding; after this instruction sizeof  will return the 5-bytes dimension you are expecting.
Proud to use LW/CVI from 3.1 on.
My contributions to the Developer Zone Community
If I have helped you, why not giving me a kudos?

Similar Messages

  • Landscape Orientation: [view bounds] gives wrong sizes?

    Hi
    Getting a view's bounds rect while in Landscape Mode returns the wrong sizes:
    Starting from a new UIView Template Project, I'm adding a single UIView to the ViewController in Interface Builder (in Landscape Mode) and setting the view size to width=400, height=200;
    However when I add a breakpoint in the ViewController (at viewDidAppear), the sizes are w=220, h=380!
    (Even though the view clearly is correct on the screen)
    In myViewController.m I've set:
    - (BOOL)shouldAutorotateToInterfaceOrientation:
    (UIInterfaceOrientation)interfaceOrientation {
    return (interfaceOrientation == UIInterfaceOrientationLandscapeRight); // home button on right
    In myAppDelegate.m
    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    application.statusBarOrientation = UIInterfaceOrientationLandscapeRight; //home on right
    [window addSubview:viewController.view];
    [window makeKeyAndVisible];
    return YES;
    and in the info.plist I've set: Initial interface orientation = Landscape (right home button)
    I'm not trying to rotate the view with the iPhone, it is meant to be fixed in Landscape only.
    Is there a workaround for this? I need to create some CALayers dependent on the correct view size.
    Thanks
    Steve

    I figured it out

  • Why is sizeof operator not in java ?

    Hello friends..
    I am having one doubt.
    Why is sizeof operator not in java ?
    Can anybody please help ?
    Thanks and Regards
    Rohit.

    An object often refers to other objects. These object may or may not have multiple references (so counting them more than once is not accurate) The actual amount of memory used is often greater than you might expect if you are used to C/C++. The system also uses memory in sometime unpredicable ways. Many methods create transient objects adding to your memory requirement. Shared libraries, the stack, the JVM itself do not appear in the heap size but use memory. Files accessed by the application can be significantly effect the desirable file cache size.
    The only real way to determine your application's memory requirement is to actively test the application, anything else is just guess work.

  • Wrong size printing

    HP 2570 Photosmart
    Running windows XP
    No messages
    No known changes
    The past two days, my HP 2570 has been printing certain files the wrong size.  I have a graphics design program (basically line art) which is supposed to print my design at actual size.  The design has a background of a 1" by 1" grid. 
    Until recently, I have had no problems.  Now, when I try to print a design, the print preview shows the image as it should appear, but the printed image is reduced to about 87% of the actual size.  This is easy to verify - I measure the spacing of the grid lines - they are 7/8" apart. 
    I printed the same design on two different days, and the two printed images are NOT the same size. 
    The only thing which I can find which seems unusual is that when I look at the printer driver details, I find FIVE different files.  They are:
    C:\\windows\system32\drivers\serscan.sys
    .....................................hpotiop2.dll
    .....................................hpovst09.dll
    .....................................hpowiamd.dll
    .....................................hpzc3212.dll
    Any ideas?

    Hi,
    Sorry to hear you are having problems printing.
    What model of printer do you have and what device/operating system are you using to print?
    "Although I work for HP, I'm speaking for myself and not on behalf of HP"
    "Say "Thanks" by clicking the Kudos Star in the post that helped you.
    --Please mark the post that solves your problem as "Accepted Solution"

  • After successful install, all my adobe cc docs, when open, change pointer arrow, i-beam and window to oversize. When doc closes all return to normal size. I'm on a PC. Screen res set to medium 1920x1200. Any ideas how to fix?

    After successful install, all my adobe cc docs, when open, change pointer arrow, i-beam and window elements to oversize. When doc closes all return to normal size. I'm on a PC. Screen res set to medium 1920x1200. Any ideas how to fix?

    Ok thanks Linxup I would recommend posting in the respective forums for each of those software titles as opposed to the Creative Cloud Download & Install forum.  The relevant forums are as follows:
    InDesign - InDesign
    Illustrator - Illustrator

  • On my new 15" MacBook Pro (June 2011) using Calendar I click the  corner arrow to enlarge the screen.  Now it is MORE than full size.  No arrow visible to return to small size.  Menu bar can't be grabbed.  I sweep and get back to desktop. No small screen?

    I installed Lion on my newish 15" MacBook Pro.  When using Calendar I click the  corner arrow to enlarge the screen.  Now ithe calendar is MORE than full size, no arrow visible to return to small size.  The Menu bar doesn't respond. when I try grabbing it to move the whole screen sideways.  When  I sweep I get back to desktop. I can sweep back to the calendar, but can't make it small again.  Menubar options include changing font size, but nothing about reverting to smaller window size.  Any suggestions?

    I installed Lion on my newish 15" MacBook Pro.  When using Calendar I click the  corner arrow to enlarge the screen.  Now ithe calendar is MORE than full size, no arrow visible to return to small size.  The Menu bar doesn't respond. when I try grabbing it to move the whole screen sideways.  When  I sweep I get back to desktop. I can sweep back to the calendar, but can't make it small again.  Menubar options include changing font size, but nothing about reverting to smaller window size.  Any suggestions?

  • Create custom document with wrong size

    Hi,
    I have a problem (on Sun Solaris 5.8) when I create custom document with more than 10MB size.
    I've created an agent which detects the events on a custom data type
    MYDOCUMENT (extension .mydoc).
    When I put a new document test1.mydoc (size of 10MB for example), my agent detects the new document, creates a copy, sets the class object to
    MYDOCUMENT , removes the original document and puts the copy into the same folder.
    But sometimes, the copy created has a wrong size (less then 10MB).
    How can I configure the nfs server to be sure that the agent waits for the complete size of the added document.
    I need HELP !!!!
    Thanks

    Hi Pavithra,
                    yeah you can create your custom table by entering fields in Standard.  for more details
    refer below screen shots
    Regards,
      Thangam.P

  • PDF is the wrong size from framemaker 8

    I am trying to create a PDF from Framemaker 8. The page size of the doc is US letter (216mm x 279mm)
    I am tring to change this to A4 (210mm x 297mm). Margins or extra white space is not an issue.
    Not matter what setting I change in Framemaker 8, either in the print dialog under "PDF setup" or in "Setup"
    where I am changing everything to A4 my PDF generates as 210mm x 279mm
    I have tried various job options and but still the PDF is the wrong size
    FYI I am using Frame 8/Distiller 9..
    Any ideas..?

    >Any ideas..?
    Sure, ask in http://forums.adobe.com/community/framemaker

  • Help: JPanel/JFrame display complexities, wrong size

    I am trying to make a simple game of worms.I wan't to draw a rectangle in the center of the window where in the middle the game is played and on the outside score, lives and other such things are displayed. The problem is the rectangle won't draw properly because the window is the wrong size and I don't know if it is something I am doing wrong with the panel or frame.
    import javax.swing.*;
    import java.awt.*;
    public class DemoWormPanel extends JPanel implements Runnable{
        private static final int WIDTH = 600, HEIGHT = 400;
        private Graphics dbG;
        private Image dbImage;
        private Thread animator;
        private boolean running = false;
        private Rectangle walls;
        public DemoWormPanel() {
            super();
            setSize(WIDTH,HEIGHT);
        public void startGame() {
            if (animator == null) {
                animator = new Thread(this);
                animator.start();
            running = true;
            //defining game walls at 50 pixels within panel border
            walls = new Rectangle(50, 50, WIDTH - 50, HEIGHT - 50);
        public void gameRender() {
            if (dbImage == null) {
                dbImage = createImage(WIDTH, HEIGHT);
                if (dbImage == null) {
                    System.out.println("Error creating double buffer");
                    System.exit(0);
                dbG = dbImage.getGraphics();
            dbG.setColor(Color.black);
            dbG.fillRect(0,0,WIDTH,HEIGHT);
            dbG.setColor(Color.white);
            dbG.drawRect(walls.x, walls.y, walls.width, walls.height);
        public void paintComponent(Graphics g) {
            super.paintComponent(g);
            g.drawImage(dbImage, 0, 0, this);
            g.dispose();
        public void update(Graphics g){
            paint(g);
        public void run() {
            while (running) {
                gameRender();
                repaint();
                try {
                    Thread.sleep(1000/50);
                } catch (InterruptedException e) {}
            System.exit(0);
        public static void main(String[] args) {
            DemoWormPanel wp = new DemoWormPanel();
            JFrame f = new JFrame();
            f.setTitle("Worms");
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            f.add(wp);
            f.setSize(WIDTH, HEIGHT);
            f.setVisible(true);
            wp.startGame();
    }Somewhere in there is my problem.
    What happens is that the right and bottom walls of the Rectangle are cut off of the screen because the window is not the right size. I changed the code to determine if the coordinates of the walls were accurate every iteration and they were. I also made it check the width and height every iteration by printing out this.getWidth() and this.getHeight() and found that instead of a 600 x 400 window, I have a 584 x 364. I also tried changing the panel and frame's size methods to make a new dimension instead of setting it directly from my constants and it had no effect. I also added directly to those constants to make it precisely 600 x 400 but the rectangle is still cut off, so maybe I also have a graphics issue. The only other potential issue I can think of is that I have Vista but I looked around here and searched google and found no similar issues to this.
    I am not new to java but I am also not advanced. I just started using java again after about 6 months and I have made a pong game before without this problem, on another computer though.I am at my wits end. I'll check for responses tomorrow and thank you for any help or insight you can offer.

    the problem is here
    walls = new Rectangle(50, 50, WIDTH - 50, HEIGHT - 50);
    at best the right/bottom walls will equal the frame's dimensions. try it as
    walls = new Rectangle(50, 50, WIDTH - 100, HEIGHT - 100);
    but this won't get you exactly what you want, due to the titlebar height (30?)
    slightly different version
    import javax.swing.*;
    import java.awt.*;
    class DemoWormPanel extends JPanel {
        private static final int WIDTH = 600, HEIGHT = 400;
        public DemoWormPanel() {
            setBackground(Color.BLACK);
            setPreferredSize(new Dimension(WIDTH-100,HEIGHT-100));
        public static void main(String[] args) {
            DemoWormPanel wp = new DemoWormPanel();
            JFrame f = new JFrame();
            f.setLayout(new GridBagLayout());
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            f.add(wp,new GridBagConstraints());
            f.setSize(WIDTH, HEIGHT);
            f.setVisible(true);
    }

  • FPGA: compilation error: size of concat operation is different than size of the target

    Today I got an error, for which I couldn't find a solution.
    I use the PXI-7813R FPGA, with Xilinx tools 10.1
    At compilation, the error I get is:
    Compilation failed due to a Xilinx error.
    Details:
    ERROR:HDLParsers:804 - "C:/NIFPGA/jobs/TESY1S8_X4PR8hn/NiFpgaAG_000000ce_CaseStructureFrame_0000.vhd" Line 301. Size of concat operation is different than size of the target.
    ERROR:HDLParsers:804 - "C:/NIFPGA/jobs/TESY1S8_X4PR8hn/NiFpgaAG_000000ce_CaseStructureFrame_0000.vhd" Line 372. Size of concat operation is different than size of the target.
    --> 
    Total memory usage is 185944 kilobytes
    Number of errors   :    2 (   0 filtered)
    Number of warnings :    0 (   0 filtered)
    Number of infos    :    0 (   0 filtered)
    Process "Synthesis" failed
    Start Time: 18:25:26
    End Time: 18:28:54
    Total Time: 00:03:27
    What can cause a concat size difference?

    This is by the way the configuration:
    Project: FPGAWrapperMG100125AOD.lvproj
    Target: FPGA Target (RIO0, PXI-7813R)
    Build Specification: fpga_integrator_AOD_random_access
    Top level VI: fpga_integrator_AOD_random_access.vi
    Compiling on LabVIEW FPGA Compile Cloud Service
    Compilation Tool: Xilinx 10.1
    Start Time: 05.07.2011 19:06:12
    Run when loaded to Fpga: FALSE
    Xilinx Options
    Design Strategy: Custom
    Synthesis Optimization Goal: Area
    Synthesis Optimization Effort: Normal
    Map Overall Effort Level: Default Xilinx setting
    Place and Route Overall Effort Level: High
    JobId: FNW72uPWorking Directory: C:\NIFPGA\compilation\FPGAWrapperMG100_FPGATarget_fpgaintegratorAO_9D5B4237
    The Xilinx log is attached.
    Attachments:
    XilinxLog.txt ‏80 KB

  • Printer prints wrong size

    HP 2570 Photosmart
    Running windows XP
    No messages
    No known changes
    I tried this question in the Home and Network printing forum, and after 4 days, not one person has replied, much less had an answer.
    Recently, my HP 2570 has been printing certain files the wrong size.  I have a graphics design program (basically line art) which is supposed to print my design at actual size.  The design has a background of a 1" by 1" grid. 
    Until recently, I have had no problems.  Now, when I try to print a design, the print preview shows the image as it should appear, but the printed image is reduced to about 87% of the actual size.  This is easy to verify - I measure the spacing of the grid lines - they are 7/8" apart. 
    I printed the same design on two different days, and the two printed images are NOT the same size. 
    The only thing which I can find which seems unusual is that when I look at the printer driver details, I find FIVE different files.  They are:
    C:\\windows\system32\drivers\serscan.sys
    .....................................hpotiop2.dll
    .....................................hpovst09.dll
    .....................................hpowiamd.dll
    .....................................hpzc3212.dll
    Any ideas?

    Hi there,
    Try downloading and running the print and scan doctor located here(to make sure there are no software issues causing the problem):
    http://h10025.www1.hp.com/ewfrf/wc/document?docnam​e=c03275041&cc=us&dlc=en&lc=en
    It can fix a lot on its own and if not give a better idea of what is going on.
    Best of Luck!
    You can say thanks by clicking the Kudos Star in my post. If my post resolves your problem, please mark it as Accepted Solution so others can benefit too.

  • Inadvertently the typesize on the iPad screen has increased until it is impossible to read the screen.  Can someone tell me how to return the type size to standard please.

    As a newcomer to the iPad, can you please tell me how to return the font size to standard. Somehow I've enlarged the font size until it's unreadable and it applies to the icons as well!  Many thanks in anticipation.

    Try this:
    Settings>General>Accessibility>Zoom>Off

  • How to i get my screen to return to normal size after accidentally zooming it in

    How do I get my screen to return to normal size after accidentally zooming in

    Pinch it, or double tap.

  • Site previews fine in Firefox locally, but when I published the site all the text is the wrong size

    I am a rookie web designer. I recently created a site using CS6. http://www.joshuahetzler.com When I previewed the site in Dreamweaver it looked good in Firefox and IE. I published the site and now it is messed up in Firefox. All the text is the wrong size. Does anyone know how to fix this? Does it have something to do with my hosting provider? (I deleted a wordpress site from the directory an hourago and put this new site in its place) Why does IE display properly, but not Firefox...

    Caused by a bad link to your site's CSS file.  This is pointing to a file on your local hard drive which nobody but you can see.
    <link href="file:///C|/hetzlerj/jhgc/menu.css" rel="stylesheet" type="text/css" />
    Open your template and reconcile the path to your site folder.  It should probably look like this:
    <link href="../menu.css" rel="stylesheet" type="text/css" />
    Save Template.  Populate changes to Child pages.  Upload Child pages.
    Nancy O.

  • Failover Cluster Manager : Add node wizard Error " This operation returned because the timeout period expired" Windows Server 2012

    Hi Everybody,
    I have two node cluster and trying to add the third node (which is a Virtual Machine), all nodes are in different subnet and can communication with each other. While adding the third node it gives the error at the end of wizard "  This operation
    returned because the timeout period expired ". My domain controller is 2008 Enterprise Server and nodes are all running Windows Server 2012 Standard Edition. Any idea what is causing the issue.
    thanks 

    Hi,
    Before you add a server (node) to a failover cluster, we strongly recommend that you run the Validate a Configuration Wizard for the existing cluster nodes and the new node
    or nodes. The Validate a Configuration Wizard helps you confirm the configuration in a variety of important ways. For example, it validates that the server to be added is connected correctly to the networks and storage and that it contains the same software
    updates. Please post the error or warning report.
    Please try to install the Recommended hotfixes and updates for Windows Server 2012-based failover clusters:
    Recommended hotfixes and updates for Windows Server 2012-based failover clusters
    http://support.microsoft.com/kb/2784261
    Hope this helps.
    We
    are trying to better understand customer views on social support experience, so your participation in this
    interview project would be greatly appreciated if you have time.
    Thanks for helping make community forums a great place.

Maybe you are looking for

  • Photoshop CS6 x64, Windows 8 64-bit and an error in my display driver

    So I have 64-bit Windows 8, 64-bit Photoshop CS6 and an ATI Radeon HD 4770 GPU. When I go to the settings in PS, it tells me that there is a problem with my display driver so I cannot use GPU graphics processing. I would really like these features to

  • Followup service contract to sales order

    Hi experts, Can I create a  Sales Order from Service contract, If Yes can I get products in Sales Order.Actully I am getting the products in sales order product Tab,but I am not getting that information in General tab. I want to get the data in gener

  • Acrobat Reader for pearl 8130?

    Just wondering if anyone knows where to get acrobat reader for Blackberry Pearl 8130. I can't find it for this phone. Thanks to anyone who can help! Solved! Go to Solution.

  • Bridge CC - What's News (and Valid for Final Version)?

    Hi, with Photoshop CC, is there any important new development about Bridge CC? I am *mainly* interested in news concerning the final shipping versions available to everybody, not any pre-release versions for insiders. So far, regarding Bridge i colle

  • IPad movie rentals

    I downloaded a movie rental on my iPad but I can't find where it is stored