From Saturday, Nov 23rd 7:00 PM CST - Sunday, Nov 24th 7:45 AM CST, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

data alignment

Which is the data alignment of Labwindows CVI compiler? Byte, word,
double word or quad word? Is there a way to change it?
thanks.
0 Kudos
Message 1 of 5
(3,727 Views)
I believe that CVI is 4 byte aligned by default, but I'm not positive. You can change it though in the same way you would in other C compilers, with a pragma pack statement, i.e.

#pragma pack (1)

would set your alignment to 1 byte. See the National Instruments Knowledgebase here.

Best Regards,

Chris Matthews
National Instruments
0 Kudos
Message 2 of 5
(3,727 Views)
Are you taking about structure alignments? Take a look at pragma directive
in online help.


vishi

"Elio Fungi" wrote in message
news:55dac88b.0302040252.78c519d1@posting.google.com...
> Which is the data alignment of Labwindows CVI compiler? Byte, word,
> double word or quad word? Is there a way to change it?
> thanks.
0 Kudos
Message 3 of 5
(3,727 Views)
The default alignment for CVI is 8 (as reported by the __DEFALIGN macro).
--
Martin
Certified CVI Developer
0 Kudos
Message 4 of 5
(3,727 Views)

I found the BOOL type occupies 4bytes instead of one BYTE. Hence declare BYTE in place of BOOL. Other date types does not have any influence.

 

Chcek the structure size with BYTE instead of BOOL.... You will get what you want 

 

 

#pragma pack(push,PLC_TO_HMI,1)//pop,1)//,MyPackedData,1) 

 typedef struct

{

                INT16 ifMachineMode;

                char sMessage[101];

                char sAlaram[101];

                BYTE bfAutoOn;

                BYTE bfAutoDone;

                float LoadArray[10000];

                double DistanceArray[10000];

                float TorqueArray[10000];

                double AngleArray[10000];

                float rfUnlockLoadResult;

                double rfUnlockAngleResult;

                INT16 ifUnlockPlotPoints;

                INT16 ifTiltPlotPoints;

                INT16 ifLockPlotPoints;

                float rfLockLoadResult;

                double rfLockAngleResult;

                double rfSlipDistanceResult;

                float rfTiltLoadResult;

                INT32 ifAdLoad;

                INT32 ifAdTorque;

                BYTE bfPassMsg;

                BYTE bfFailMsg;

                INT16 ifCycleDone;

                INT16 ifOkCount;

                INT16 ifNgCount;

                float rfCycleTime;

                float rfCurrentLoad;

                double rfCurrentDistance;

                float rfCurrentTorque;

                double rfCurrentAngle;

                BYTE Blinker500;

} PLC_TO_HMI;

PLC_TO_HMI Plc2Hmi;

 

0 Kudos
Message 5 of 5
(3,194 Views)